Finding a physical property ID?

Finding a physical property ID?

paulZKN98
Advocate Advocate
303 Views
2 Replies
Message 1 of 3

Finding a physical property ID?

paulZKN98
Advocate
Advocate

I am new to iLogic (but excited to learn!!), I am trying to modify this code from a older post  to display the Sheetmetal thickness in my view's text box . The goal being to use this in our dedicated Sheetmetal drawing template.  I would like to change the code's MASS to the part's "Thickness" defined in my Sheetmetal rules. 

 

Am I able to replace the PhysicalPropertyID Number in this line: <PhysicalProperty PhysicalPropertyID='72449'  to whatever the ID number for the "Thickness" Parameter?  And if so how do I find this number?  You may need to talk slow as I'm brand new to this!  I'm grateful for any suggestions you all may offer, Many thanks in advance! 

 

 

Source: https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/ilogic-code-to-change-view-label-text/t...

Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
If oSSet.count = 0 Then
	MessageBox.Show("You must select a drawing view first", "iLogic")
Exit Sub
End If

'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView = trycast(oSSet.item(1), DrawingView)

If oView IsNot Nothing Then
oView.ShowLabel = True
'format the model iproperties	
oDescription = "<StyleOverride Underline='True'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
oPartNumber = "<StyleOverride Underline='True'> - Mk <Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride>"
oStringMass = "<Br/><StyleOverride Underline='False' FontSize='0.35'>EST UNIT MASS = <PhysicalProperty PhysicalPropertyID='72449' Precision='2'>MASS</PhysicalProperty></StyleOverride>"
oStringScale = "<Br/><StyleOverride FontSize='0.3'>(Scale <DrawingViewScale/>)</StyleOverride>"

'add to the view label
oView.Label.FormattedText =  oDescription & oPartNumber & oStringMass & oStringScale	    

Else
	MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If

 

0 Likes
304 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor

The easiest way to get the information is to manually create the label that you want. Then run the following rule. Select the view with the label. The information will then be written to your logger.

Dim view = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select drawing view")
Logger.Info(view.Label.FormattedText)

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 3

WCrihfield
Mentor
Mentor

Hi @paulZKN98.  Dealing with the FormattedText of a DrawingView Label when you are just getting started with iLogic, is probably similar to jumping off the deep end of a pool when you are just starting to learn how to swim. 🙂  Partly because it also mixes coding for XML tags, and there is not much documentation about working with them in Inventor.  Here is a link to an online help page about dealing with the FormattedText that may help, or may just confuse you more.

So basically, no.  Simply changing that PhysicalPropertyId number won't do what you want.  You will need to completely replace your 'oMassString' line(s) of code with different code, because a physical property is a different type of source object than a parameter, so the XML tags you will need to use will be different.  The best way to figure it out might be to reverse engineer it.  What I mean by that is to create the label as you want it manually, using the Format Text dialog box, then investigate what the code looks like behind the resulting FormattedText when it is all set-up the way you want it.  Then you can use that knowledge to repeat the needed code in your iLogic rule.

Here is an iLogic rule you can use to do that:

oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a Drawing View.")
If IsNothing(oObj) Then Exit Sub
If Not TypeOf oObj Is DrawingView Then Exit Sub
Dim oView As DrawingView = oObj
oFText = oView.Label.FormattedText
a = InputBox("", "Label FormattedText", oFText)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes