<?xml encoding=”UTF-8″>By Adam Nagy
If you created a DrawingSketch and placed some geometry there which you dimensioned (constrained), then you can drive the value of those.
In the UI if you wanted to change the dimension then you would either go into the sketch and double-click the dimension or modify it from the Parameters dialog. In both cases you are modifying the parameter that drives the dimension constraint to achieve what you need.
You would have to do exactly the same through the API as well. If you want to get to them for some reason through Sheet.DrawingDimensions.GeneralDimensions, that is possible too. From that collection you would get back e.g. a LinearGeneralDimension. Its DimensionText property can only modify what is shown in the UI for the dimension not the actual size of it:
You can use the RetrievedFrom property to get to the Sketch dimension constraint, which will provide you the Parameter you need to modify.
Sub ModifyDimensions()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDoc.ActiveSheet
Dim oTO As TransientObjects
Set oTO = ThisApplication.TransientObjects
Dim oSketches As ObjectCollection
Set oSketches = oTO.CreateObjectCollection
Dim oDrawingDim As GeneralDimension
For Each oDrawingDim In oSheet.DrawingDimensions.GeneralDimensions
Dim dimGeneralDimText As DimensionText
Set dimGeneralDimText = oDrawingDim.text
Dim p As Parameter
Set p = oDrawingDim.RetrievedFrom.Parameter
p.Value = p.Value + 1 ' adding 1 cm to it
' Note the sketch that will need an update
Call oSketches.Add(oDrawingDim.RetrievedFrom.Parent)
Next
' Update the sketches
Dim oSketch As DrawingSketch
For Each oSketch In oSketches
Call oSketch.Edit
Call oSketch.Solve
Call oSketch.ExitEdit
Next
End Sub
Iterating through the DrawingSketch.DimensionConstraints collection would be an even simpler solution.



Leave a Reply