- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have a model of a part that has 3 size options. I want the drawing associated with this part to be automatic.
I almost got it done, but when I change the drawing view scale based on the model size, the dimension text is not centered. In another topic I found a rule that centers the dimension text, which works fine when I run it manually when the drawing is open, but when it should be automatic (run by another rule) it does not work, well the rule is executed but the text is not centered before the drawing save and close operation.
1st rule that changes the drawing view scale and then executes the second rule.
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oModelDoc As PartDocument = oDoc.ReferencedDocuments.Item(1)
Dim oDimensionA As Double = (oModelDoc.ComponentDefinition.Parameters.Item("Width").Value) * 10
Dim oScale As String
Dim oView As DrawingView
If oDimensionA = 300 Then
oScale = "1 : 2"
ElseIf oDimensionA = 450 Then
oScale = "1 : 2.5"
ElseIf oDimensionA = 650 Then
oScale = "1 : 3"
End If
For Each oView In oDoc.ActiveSheet.DrawingViews
If oView.ScaleFromBase = False
oView.ScaleString = oScale
End If
Next
RuleParametersOutput()
InventorVb.DocumentUpdate()
iLogicVb.UpdateWhenDone = True
iLogicVb.RunRule("Center Dimension Text")
2nd rule "Center Dimension Text" that should center the dimension text. When I run it manually after the 1st rule the dimension text is centered, but when the rule is run automatically by the 1st rule, then the text is not centered when I open the drawing.
Dim oDoc As DrawingDocument = ThisDoc.Document
'Set a reference to the active sheet
Dim oSheet As Sheet
Dim oDrawingDim As DrawingDimension
'Iterate over all dimensions in the drawing and center them if they are linear or angular.
For Each oSheet In oDoc.Sheets
For Each oDrawingDim In oSheet.DrawingDimensions
If TypeOf oDrawingDim Is LinearGeneralDimension Or
TypeOf oDrawingDim Is AngularGeneralDimension Then
Call oDrawingDim.CenterText
End If
Next
Next
RuleParametersOutput()
InventorVb.DocumentUpdate()
iLogicVb.UpdateWhenDone = True
oDoc.Save
oDoc.Close
I cannot share the file for copyright reasons, but if needed I could create a sample file of something else.
Solved! Go to Solution.