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: 

iLogic External to write and read from user parameters.

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
841 Views, 4 Replies

iLogic External to write and read from user parameters.

Hi there.

 

I am trying to create an external rule to check if parameters do exist and if not create it, and I fail to understand the correct steps and proceudres to follow to make it happen. I am tying to keep it very simple. I have two text parameters:

SetComments: This is used to set the iPoroperties Comments value with in part rule stating: iProperties.Value("Summary", "Comments") = SetComments

 

FileType: This is used to get the file sub type into a user parameter so that I can display it on a Form. the current in part rule is: File_Tipe = iProperties.Value("Project", "File)

 

But I don't want to go through all my parts and manually add these rules and user parameter to each and every part.

Ideally, I would like it to be controlled via External rule, then I only have to set the rule up once and just run it from there.

4 REPLIES 4
Message 2 of 5
J-Camper
in reply to: Anonymous

I think this will do what you're looking for:

Sub Main
	'set active document parameters
	Dim paramNames As String() = {"FillComments", "FileType" }
	For i As Integer = 0 To paramNames.Count-1
		Call Formatting(ThisApplication.ActiveDocument, paramNames(i))
	Next
	Call LinkiProperties(ThisApplication.ActiveDocument,paramNames)
	'handle assembly occurrences
	If ThisApplication.ActiveDocumentType = kAssemblyDocumentObject
		For Each oOcc As ComponentOccurrence In ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.AllLeafOccurrences
			For i As Integer = 0 To paramNames.Count-1
				Call Formatting(oOcc.Definition.Document, paramNames(i))
			Next
			Call LinkiProperties(oOcc.Definition.Document,paramNames)
		Next
	End If
End Sub

Sub Formatting(oDoc As Document, name As String)
	Try
		param = oDoc.ComponentDefinition.Parameters.Item(name)
	Catch
		param = oDoc.ComponentDefinition.Parameters.UserParameters.AddByValue(name, "filler", kTextUnits)
	End Try	
End Sub

Sub LinkiProperties(oDoc As Document, allStrings As String())
	oDoc.PropertySets.Item("Inventor Summary Information").Item("Comments").Value = oDoc.ComponentDefinition.Parameters.Item(allStrings(0)).Value ' "<" & allStrings(0) & ">"
	oDoc.ComponentDefinition.Parameters.Item(allStrings(1)).Value = oDoc.PropertySets.Item("Design Tracking Properties").Item("Document SubType Name").Value
End Sub

You can run from part or assembly and if run in an assembly it will run through all occurrences in the assembly

Message 3 of 5
Anonymous
in reply to: J-Camper

Hi @J-Camper 

Thank you. But should I run this from an iLogic rule or VBA?

Message 4 of 5
J-Camper
in reply to: Anonymous

I wrote it for iLogic, you should be able to save it as an external rule

Message 5 of 5
Anonymous
in reply to: J-Camper

Thank you. The code worked.

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report