In drawing document, draft view also contains sketch with the similar functionalities of genetic sketch in part or assembly. While it looks the dimension constraint of the sketch entities are not managed by Parameter in the document.
With API, we can still access these parameters and manipulate them directly. The VBA code demos a workflow to change a specific parameter of a specific sketch of a specific draft view. Since draft view could have the same name, the code uses index as a unique identification.
Sub test()
Call changeDraftSketchConstaintParam(1, "d0", "200 in")
End Sub
Sub changeDraftSketchConstaintParam(draftIndex, paramName, newV)
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDoc.ActiveSheet
Dim oView As DrawingView
Set oView = oSheet.DrawingViews(1)
If oView.ViewType = kDraftDrawingViewType Then
Dim oDraftSketch As Sketch
Set oDraftSketch = oView.Sketches(draftIndex)
If Not oDoc.ActivatedObject Is oDraftSketch Then
oDraftSketch.Edit
End If
Dim oDim As DimensionConstraint
For Each oDim In oDraftSketch.DimensionConstraints
Dim oParam As Parameter
Set oParam = oDim.Parameter
If oParam.Name = paramName Then
oParam.Expression = newV
End If
Next
oDraftSketch.Solve
oDraftSketch.ExitEdit
End If
oDoc.Update
End Sub .
iLogic does not provide a direct module to access these parameters, but the same VBA code could be used in iLogic with just a little bit modification:
Sub Main()
Call changeDraftSketchConstaintParam(1, "d0", "200 in")
End Sub
Sub changeDraftSketchConstaintParam(draftIndex, paramName, newV)
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
Dim oView As DrawingView
oView = oSheet.DrawingViews(1)
If oView.ViewType = kDraftDrawingViewType Then
Dim oDraftSketch As Sketch
oDraftSketch = oView.Sketches(draftIndex)
If Not oDoc.ActivatedObject Is oDraftSketch Then
Call oDraftSketch.Edit()
End If
Dim oDim As DimensionConstraint
For Each oDim In oDraftSketch.DimensionConstraints
Dim oParam As Parameter
oParam = oDim.Parameter
If oParam.Name = paramName Then
oParam.Expression = newV
End If
Next
Call oDraftSketch.Solve()
Call oDraftSketch.ExitEdit()
End If
Call oDoc.Update()
End Sub