Get expression of Design Tracking/ User Defined Properties from within Drawing

Get expression of Design Tracking/ User Defined Properties from within Drawing

RoyWickrama_RWEI
Advisor Advisor
849 Views
3 Replies
Message 1 of 4

Get expression of Design Tracking/ User Defined Properties from within Drawing

RoyWickrama_RWEI
Advisor
Advisor

From within the drawing document, I am trying to retrieve the expression of the properties of the model document. I am trying with the following code (for design tracking properties). I can't get this, I believe!

 

oModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
Dim invDesignProps As PropertySet
invDesignProps = oModelDoc.PropertySets.Item("Design Tracking Properties")
Dim invProperty_Tracking As Inventor.Property
MessageBox.Show("invDesignProps.Count: " & InvDesignProps.Count, oRuleNo)
Dim invCustomProps As PropertySet
invCustomPros = oModelDoc.PropertySets.Item("Inventor User Defined Properties")
Dim invProperty_Custom As Inventor.Property
MessageBox.Show("invCustomProps.Count: " & invCustomPros.Count, oRuleNo)
    ' Get the design tracking property set.
	For Each invProperty_Tracking In InvDesignProps
'		MessageBox.Show("invProperty_Tracking.Expression: " & invProperty_Tracking.Expression, oRuleNo)
				If invProperty_Tracking.Name = "Description" Then
					MessageBox.Show("invProperty_Tracking.Expression: " & invProperty_Tracking.Expression, oRuleNo)
				End If
	Next invProperty_Tracking

I request help.

 

The rule below works for parts (and assemblies: may not be required)

Sub Main()
oRuleNo = "iL0061"

    oDoc = ThisApplication.ActiveDocument

    Dim invDesignProps As PropertySet
    invDesignProps = oDoc.PropertySets.Item("Design Tracking Properties")
	Dim invProperty_Tracking As Inventor.Property
'	MessageBox.Show("invDesignProps.Count: " & InvDesignProps.Count, oRuleNo)

	Dim invCustomProps As PropertySet
	invCustomPros = oDoc.PropertySets.Item("Inventor User Defined Properties")
	Dim invProperty_Custom As Inventor.Property
'	MessageBox.Show("invCustomProps.Count: " & invCustomPros.Count, oRuleNo)

    ' Get the design tracking property set.
	For Each invProperty_Tracking In InvDesignProps

				If invProperty_Tracking.Name = "Description" Then
					MessageBox.Show("invProperty_Tracking.Expression (Description): " & invProperty_Tracking.Expression, oRuleNo)
					Exit Sub
				Else
''		MessageBox.Show("invProperty_Tracking.Expression: " & invProperty_Tracking.Expression, oRuleNo)
'		For Each invProperty_Custom In invCustomPros		'i = 0 To invCustomPros.count-1
'	'		MessageBox.Show("invProperty_Tracking.Expression: " & invProperty_Tracking.Expression, oRuleNo)
''				If invProperty_Tracking.Expression = invProperty_Custom.Expression Then
'				If invProperty_Custom.Name = "Length_Test" Then
'					MessageBox.Show("invProperty_Custom.Expression: " & invProperty_Custom.Expression, oRuleNo)
'					Exit Sub
'				Else
''					oYN = MessageBox.Show("Continue?", oRuleNo, MessageBoxButtons.YesNo)
''					If oYN = vbNo Then Exit Sub
				End If
'		Next invProperty_Custom
	Next invProperty_Tracking
End Sub

 

 

0 Likes
Accepted solutions (2)
850 Views
3 Replies
Replies (3)
Message 2 of 4

RoyWickrama_RWEI
Advisor
Advisor
Accepted solution

I further explored the code I am working currently. I got it doing well. See the attachment.

My thanks goes to Chandra Shekar Gopal.

 

Capture-2.PNG

However, I welcome any comments and suggestions.

 

0 Likes
Message 3 of 4

RoyWickrama_RWEI
Advisor
Advisor
Accepted solution

I further simplified and expanded. Sample rule is attached.

0 Likes
Message 4 of 4

RoyWickrama_RWEI
Advisor
Advisor

Complete solution!

0 Likes