Using ilogic for force update model physical properties when idw is save

Using ilogic for force update model physical properties when idw is save

Darkforce_the_ilogic_guy
Advisor Advisor
1,062 Views
4 Replies
Message 1 of 5

Using ilogic for force update model physical properties when idw is save

Darkforce_the_ilogic_guy
Advisor
Advisor

I have a problem that something mass is show as N/A

bt_0-1665565349842.png

It got the vaule form Phsical Propertoes - model - Mass

bt_1-1665565397450.png

how can I update the model with ilogic form idw ? så it show the right weight. 

 

it does this automatic if I open the model but I want it to happen without have to remember to open the model if the vault is N/A

bt_2-1665566283315.png

 

 

 

 

 

0 Likes
1,063 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @Darkforce_the_ilogic_guy.  As far as code that would automatically check the value of the text box within your drawing, that would require knowing exactly how to find that specific TextBox object within the DrawingSketch of the TitleBlockDefinition of your current TitleBlock, which can be difficult to do, especially for someone remote, without your drawing file to test on.  As for updating the model's Mass from the drawing...I think I may be able to help with that part.  Below is a fairly simple iLogic rule that basically just visibly opens the model document, then updates it, then executes a command that causes its Mass Properties to be updated.  Then it saves and visibly closes that model document again.  Then it updates the drawing.  Hopefully this will do the task for you.

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oModelDoc As Document = ThisDrawing.ModelDocument
oModelDoc = ThisApplication.Documents.Open(oModelDoc.FullDocumentName, True)
Dim oCD As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd")
oModelDoc.Update2(True)
oCD.Execute2(True)
oModelDoc.Save2(True)
oModelDoc.Close(True)
oDDoc.Update2(True)

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5

WCrihfield
Mentor
Mentor

Hi @Darkforce_the_ilogic_guy.  Based on the image you provided for how that TextBox's contents were defined, I created some iLogic code for finding that specific TextBox in the TitleBlock of the active drawing sheet, then checks its current resulting value.  Then I just have a commented line in there where you would either insert some of the other code for updating it, or run the other rule at that point.

If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing document must be active for this code to work. Exiting.", vbCritical, "")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
If oSheet.TitleBlock Is Nothing Then Exit Sub
Dim oTB As TitleBlock = oSheet.TitleBlock
Dim oTBDef As TitleBlockDefinition = oTB.Definition
Dim oSketch As DrawingSketch = oTBDef.Sketch
If oSketch.TextBoxes.Count = 0 Then Exit Sub
Dim oMassTB As Inventor.TextBox = Nothing
For Each oTBox As Inventor.TextBox In oSketch.TextBoxes
	If oTBox.FormattedText = "<PhysicalProperty PhysicalPropertyID='72449' Precision='3'>MASS</PhysicalProperty>" Then
		oMassTB = oTBox
	End If
Next
If oTB.GetResultText(oMassTB) = "N/A" Then
	'run that other code here
End If

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 5

Darkforce_the_ilogic_guy
Advisor
Advisor

I get this error .. and seems to be line 18 that fail.  might be because it never find the textbox as the if statment never become true for some reason

 

If oTBox.FormattedText = "<PhysicalProperty PhysicalPropertyID='72449' Precision='3'>MASS</PhysicalProperty>" Then

 

I belive your other code work as plan 

 

 

0 Likes
Message 5 of 5

WCrihfield
Mentor
Mentor

Hi @Darkforce_the_ilogic_guy.  I think I see where it might be slightly off.  Within the String it is checking, I have "Precision='3'", but I think you may need it to be "Precision='1'", because you had your precision within the dialog box set to 1,1.  You could probably just change the "3" to "1", to fix it.  Sorry about that.  When I created my example to test, I did not have my precision set the same as yours.

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes