AbhishekParvat
Mechanical
- May 30, 2023
- 2
Hello, i am facing issue while creating dimension in drawing document. Actually it generating all the dimension at one point. I am sharing my code
Private Sub length_dim1_Click()
Dim CATIA As Object
Dim drawingdocumentdim1 As Object
Dim drawingsheetsdim As Object
Dim drawingsheetdim As Object
Dim drawingviewsdim As Object
Dim drawingviewdim As Object
Dim strLine As String
Dim line1 As Line2D
Dim linesel1 As Object
Dim inputline()
Dim statussel3
Dim selpoint(1)
Dim selpoints(3)
selpoints(3) = Array(150, 10, 120, 100)
selpoint(0) = 0
selpoint(1) = 0
' Set CATIA application
Set CATIA = GetObject(, "CATIA.Application")
' Get the active drawing document
Set drawingdocumentdim1 = CATIA.ActiveDocument
Set drawingsheetsdim = drawingdocumentdim1.Sheets
Set drawingsheetdim = drawingsheetsdim.ActiveSheet
' Get the active drawing view
Set drawingviewsdim = drawingsheetdim.Views
Set drawingviewdim = drawingsheetdim.Views.ActiveView
' Initialize the object selection for lines
Set linesel1 = drawingdocumentdim1.selection
' Prompt user for auto dimensions
answermsg1 = MsgBox("Do you want auto dimensions", vbYesNo + vbSystemModal, "")
If answermsg1 = vbYes Then
' Search for all lines
strLine = "Drafting.Line,all"
linesel1.Search strLine
Else
' Prompt user to select line
MsgBox "Select Curve"
inputline(0) = "AnyObject"
statussel3 = linesel1.SelectElement3(inputline, "select Curve", False, CATMultiSelectionMode.CATMultiSelTriggWhenUserValidatesSelection, False)
If statussel3 = "Cancel" Then
Exit Sub
End If
End If
' Get the count of selected lines
Dim icount
icount = linesel1.Count
' Loop through selected lines and add length dimensions
Dim i
[highlight #FCE94F] For i = 1 To icount
' Get the selected line
Set line1 = linesel1.Item(i).Value
ReDim inputline(0 To i)
inputline(i) = Array(line1)
' Add length dimension to the drawing view
drawingviewdim.Dimensions.Add CatDimType.catDimLength, inputline(i), selpoints(3), CatDimLineRep.catDimAuto
Next i[/highlight]
End Sub
Private Sub length_dim1_Click()
Dim CATIA As Object
Dim drawingdocumentdim1 As Object
Dim drawingsheetsdim As Object
Dim drawingsheetdim As Object
Dim drawingviewsdim As Object
Dim drawingviewdim As Object
Dim strLine As String
Dim line1 As Line2D
Dim linesel1 As Object
Dim inputline()
Dim statussel3
Dim selpoint(1)
Dim selpoints(3)
selpoints(3) = Array(150, 10, 120, 100)
selpoint(0) = 0
selpoint(1) = 0
' Set CATIA application
Set CATIA = GetObject(, "CATIA.Application")
' Get the active drawing document
Set drawingdocumentdim1 = CATIA.ActiveDocument
Set drawingsheetsdim = drawingdocumentdim1.Sheets
Set drawingsheetdim = drawingsheetsdim.ActiveSheet
' Get the active drawing view
Set drawingviewsdim = drawingsheetdim.Views
Set drawingviewdim = drawingsheetdim.Views.ActiveView
' Initialize the object selection for lines
Set linesel1 = drawingdocumentdim1.selection
' Prompt user for auto dimensions
answermsg1 = MsgBox("Do you want auto dimensions", vbYesNo + vbSystemModal, "")
If answermsg1 = vbYes Then
' Search for all lines
strLine = "Drafting.Line,all"
linesel1.Search strLine
Else
' Prompt user to select line
MsgBox "Select Curve"
inputline(0) = "AnyObject"
statussel3 = linesel1.SelectElement3(inputline, "select Curve", False, CATMultiSelectionMode.CATMultiSelTriggWhenUserValidatesSelection, False)
If statussel3 = "Cancel" Then
Exit Sub
End If
End If
' Get the count of selected lines
Dim icount
icount = linesel1.Count
' Loop through selected lines and add length dimensions
Dim i
[highlight #FCE94F] For i = 1 To icount
' Get the selected line
Set line1 = linesel1.Item(i).Value
ReDim inputline(0 To i)
inputline(i) = Array(line1)
' Add length dimension to the drawing view
drawingviewdim.Dimensions.Add CatDimType.catDimLength, inputline(i), selpoints(3), CatDimLineRep.catDimAuto
Next i[/highlight]
End Sub