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: 

Custom iProperties add to selected parts

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
kresh.bell
366 Views, 7 Replies

Custom iProperties add to selected parts

I have this iLogic which works great for me. I add a description in the assembly environment by selecting the parts. When I'm done click escape.

 

Dim oOccurrence As ComponentOccurrence

msg = "Select a component (press ESC to exit)"
While True
	oOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, msg)

	' If nothing gets selected then we're done	
	If IsNothing(oOccurrence) Then Exit While

	oName = oOccurrence.Name

	ThisApplication.ActiveDocument.selectset.select(oOccurrence)
	oDesc = iProperties.Value(oName, "Project", "Description")
	oDesc = InputBox(oName & " Description", "iLogic", oDesc)
	If Not oDesc = Nothing Then iProperties.Value(oName, "Project", "Description") = oDesc

End While

 


I am interested in whether it is possible to first create a custom iproperty (in case it does not exist) and then add a value to it in the same way in the assembly environment. The name custom iLogic does not need to be created through the toolbox, through iLogic is perfectly fine.
If it is possible to use the same iLogic also in a part environment, that would be really great

7 REPLIES 7
Message 2 of 8
Michael.Navara
in reply to: kresh.bell

You need just to wrap property value obtaining to Try-Catch. 

 

Dim oOccurrence As ComponentOccurrence

msg = "Select a component (press ESC to exit)"
While True
	oOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, msg)

	' If nothing gets selected then we're done	
	If IsNothing(oOccurrence) Then Exit While

	oName = oOccurrence.Name

	ThisApplication.ActiveDocument.SelectSet.Select(oOccurrence)
	oDesc = iProperties.Value(oName, "Project", "Description")
	oDesc = InputBox(oName & " Description", "iLogic", oDesc)
	If Not oDesc = Nothing Then iProperties.Value(oName, "Project", "Description") = oDesc

	'Custom description
	Dim customDesc As String
	Try
		customDesc = iProperties.Value(oName, "Custom", "CustomDescription")
	Catch
		customDesc = ""
	End Try
	customDesc = InputBox(oName & " Custom Description", "iLogic", customDesc)

	If Not customDesc = Nothing Then iProperties.Value(oName, "Custom", "CustomDescription") = customDesc

End While

 

 

Message 3 of 8
kresh.bell
in reply to: kresh.bell

thanks, realy nice

Message 4 of 8
kresh.bell
in reply to: Michael.Navara

Hi,

one more thing.

 

Is it possible to make a rule for part envirovment that, when runing, checks if there is a custom property name eg "Sample"? If it does not exist, it will be created. In both cases (exist or no), after that, a small window will open with the possibility to add or change value for that custom property.

Message 5 of 8
Michael.Navara
in reply to: kresh.bell

This is the same code (lines 17 - 26) without argument oName 

Message 6 of 8
kresh.bell
in reply to: Michael.Navara

Uncordiality,

it's not possible select part in part environment

 

Screenshot 2024-04-10 152259.png

Message 7 of 8
Michael.Navara
in reply to: kresh.bell

OK 😀

Try this code in part. If you want to change iProperties of the document where you run the rule, you don't need to select anything.

 

'Custom description
Dim customDesc As String
Try
	customDesc = iProperties.Value("Custom", "CustomDescription")
Catch
	customDesc = ""
End Try
customDesc = InputBox("Custom Description", "iLogic", customDesc)

If Not customDesc = Nothing Then iProperties.Value("Custom", "CustomDescription") = customDesc

 

Message 8 of 8
kresh.bell
in reply to: kresh.bell

thanks, it works

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

Post to forums  

Autodesk Design & Make Report