- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is there a way to replace the physical properties precision in the title block of a drawing using iLogic?
I know I can create a custom property to adjust the accuracy, but I only want to change the precision in the title block.
Simply, replace MASS\P1; with MASS\P2;
I have searched the forums and haven't found the solution to the mass precision.
Solved: iLogic Insert Text Parameter into a Text Field - Autodesk Community - Inventor
Fixed: Change Titleblock Textfields with iLogic - Autodesk Community - Inventor
Thanks to anyone who can help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @dg8MW9N. This is some pretty tricky/complicated business, but I think I may have something here that might work for you. It gets the 'active' drawing document, the 'active' sheet, then the title block definition of the current title block on that sheet, then gets its sketch. Then it starts looping through each TextBox within that sketch, looking for one that contains the necessary 'FormattedText' contents for the Mass physical property. Here is the online help page for dealing with FormattedText. If it finds one, it then tries to replace the current 'Precision' part with the other 'toggled' value. When done, it saves the modified sketch back over the definition, updating the current title block.
Give this iLogic rule a try.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule to work. Exiting.",vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDDoc.ActiveSheet
If oSheet.TitleBlock Is Nothing Then Exit Sub
Dim oTBDef As TitleBlockDefinition = oSheet.TitleBlock.Definition
Dim oSketch As DrawingSketch
oTBDef.Edit(oSketch)
If oSketch.TextBoxes.Count = 0 Then Exit Sub
For Each oTBox As Inventor.TextBox In oSketch.TextBoxes
Dim oFT As String = oTBox.FormattedText
Dim oParts
'if 1 decimal place, then toggle to 2
If oFT.Contains("<PhysicalProperty PhysicalPropertyID='72449' Precision='1'>") Then
oTBox.FormattedText = Replace(oFT, "Precision='1'>", "Precision='2'>")
ElseIf oFT.Contains("<PhysicalProperty PhysicalPropertyID='kPhysicalModelMass' Precision='1'>") Then
oTBox.FormattedText = Replace(oFT, "Precision='1'>", "Precision='2'>")
'If 2 decimal places, then toggle to 1
ElseIf oFT.Contains("<PhysicalProperty PhysicalPropertyID='72449' Precision='2'>") Then
oTBox.FormattedText = Replace(oFT, "Precision='2'>", "Precision='1'>")
ElseIf oFT.Contains("<PhysicalProperty PhysicalPropertyID='kPhysicalModelMass' Precision='2'>") Then
oTBox.FormattedText = Replace(oFT, "Precision='2'>", "Precision='1'>")
End If
Next
oTBDef.ExitEdit(True)
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS)
.
If you want and have time, I would appreciate your Vote(s) for My IDEAS
or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Oh wow! This works perfectly.
I really appreciate the effort, especially since it was so complicated.
Have a great weekend!