Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

"For Each .... Next" or similar to access any of iProperties of active document

2 REPLIES 2
Reply
Message 1 of 3
RoyWickrama_RWEI
329 Views, 2 Replies

"For Each .... Next" or similar to access any of iProperties of active document

Requesting, "For Each .... Next" type of code to access in sequence all iProperties in active document

 

I have parts and sub-assemblies with some custom iProperties created in them based on their location(s) in the main assembly hierarchy. These iProperties (self-created by an iLogic running in each assembly) carry information like part number of the parent assembly and quantity in the same assembly. Although these iProperties are different and not known (for different assemblies and parts) they have a regular pattern; i.e. one set starts from "QTY" and other set starts from "PA" which is useful to filter them from others.

PT202.JPG

In this document, I want to create another set of iProperty, say Qty01, Qty02,.. . where first Qty01 will be assigned the (first) or the value of any one of QTY_A000, QTY_A200, or QTY_A210, and secondly Qty02 will be assigned the (first of remaining) or the value of any one of the remaining QTY_A200, or QTY_A210, and so on.

 

Sample part (PT202) attached.

 

To achieve this, I need to access all iProperties of the current document in sequence. I  request some one help me to get around this. This is very important in my research level of large scale assembly modelling.

 

Thanks.

 

Roy Wickrama, P. Eng.

Autodesk Inventor (Professional) - 2015

Autodesk Vault Basic - 2015

2 REPLIES 2
Message 2 of 3
NSBowser
in reply to: RoyWickrama_RWEI

I'm not 100% sure what your end goal is. I'm a little confused how your intending to use the properties after you have collected them, however, here is a sample of code that would loop through all the custom iproperties as you have asked. Here I'm just printing the value to a messagebox where your logic would differ. Hopefully this at least answers that aspect of your request.

 

 

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

Dim invCustomPropertySet As PropertySet
invCustomPropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")

For Each oProp As Inventor.Property In invCustomPropertySet
	MessageBox.Show(oProp.Value)
Next

Best of Luck

---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.
Message 3 of 3
NSBowser
in reply to: RoyWickrama_RWEI

Looking at your request again, does this accomplish what you are setting out to do?

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

Dim invCustomPropertySet As PropertySet
invCustomPropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")

Dim qtyCount As Integer
Dim qtyString As String
qtyCount = 1

For Each oProp As Inventor.Property In invCustomPropertySet
	'MessageBox.Show(oProp.Name)
	If Left(oProp.Name,4) = "QTY_" Then
		'MessageBox.Show(oProp.Name & ": " & oProp.Value)
		If qtyCount < 10 Then
			qtyString = "QTY0" & qtyCount
		Else
			qtyString = "QTY" & qtyCount
		End If
		Dim newProp As Inventor.Property
		Try
			newProp = invCustomPropertySet.Item(qtyString)
		Catch
			newProp = invCustomPropertySet.Add(oProp.Value,qtyString)
		End Try
		newProp.Value = oProp.Value
		qtyCount = qtyCount + 1
	End If
Next

Best of Luck

---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report