Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iPart integration into iAssemblies (Issues using iLogic)

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
RyanWerden
313 Views, 2 Replies

iPart integration into iAssemblies (Issues using iLogic)

I'm trying to make 100s of corrugated plastic signs with vinyl text graphics. The signs come in several different sizes, and hundreds of different text configurations.

 

I've created an iPart for the 4 different sizes of corrugated plastic. No problems.

 

I created another iPart for the first 14 vinyl text graphics (extruded text) and this is where things are starting to go sideways.

 

I want the actual text to be driven by the iPart table. The only way I found to accomplish this was to create iLogic that takes a numerical index (that can be driven by the iPart table) to drive a text user parameter.

 

Each member has a SignText_Index value of 1-14 driven by the table.

 

iLogicVb.UpdateWhenDone = True

Select Case SignText_Index

Case 1
	Parameter("SignText") = "SIGN TEXT 1"
Case 2
	Parameter("SignText") = "SIGN TEXT 2"
Case 3
	Parameter("SignText") = "SIGN TEXT 3"
Case 4
	Parameter("SignText") = "SIGN TEXT 4"
Case 5
	Parameter("SignText") = "SIGN TEXT 5"
Case 6
	Parameter("SignText") = "SIGN TEXT 6"
Case 7
	Parameter("SignText") = "SIGN TEXT 7"
Case 8
	Parameter("SignText") = "SIGN TEXT 8"
Case 9
	Parameter("SignText") = "SIGN TEXT 9"
Case 10
	Parameter("SignText") = "SIGN TEXT 10"
Case 11
	Parameter("SignText") = "SIGN TEXT 11"
Case 12
	Parameter("SignText") = "SIGN TEXT 12"
Case 13
	Parameter("SignText") = "SIGN TEXT 13"
Case 14
	Parameter("SignText") = "SIGN TEXT 14"

End Select

Now I can drive the sketch text with the "SignText" user parameter and it auto-populates based on which child I've selected. eg. Child 3 auto-populates to "SIGN TEXT 3," child 9 auto-populates to "SIGN TEXT 9," etc.

 

After this point is pure frustration. Each member needs to be manually activated before it can be generated. Failure to do so just makes all the members the same. More work than should be necessary... and I don't want to do it 200 more times.

 

And then even if I was OK with torturing myself 200+ times, when I create the iAssembly to actually put the sign pieces together (corrugated plastic + vinyl) the table looks fine, allows me to do all the "Table Replace" functions that are required, but the vinyl doesn't actually update in these members until I activate each member individually AND immediately thereafter open the corresponding vinyl iPart.

 

Does anybody have any brilliant ideas how I can streamline this workflow?

2 REPLIES 2
Message 2 of 3
A.Acheson
in reply to: RyanWerden

Are these iassemblies one offs or will they be library type files when complete? If library you could perservere with the method you have even if it is cumbersome.

 

You could write an ilogic script to do the member generation and looping through the factory file to apply the factory table changes although there is some system messages that are time consuming to clear and persistent with ilogic. Here is a code for an ipart. Ensure you have only one key for the ipart. Simply change in the code  ipart to iassembly for an iassembly factory. 

 

If there is elements of customizing you want on the fly, it sounds like then a direct ilogic assembly would solve  all the issues. If you have a small sample file set showing the workflow attach them here with some images to show the issues at hand. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 3
RyanWerden
in reply to: A.Acheson

Just wanted to give a thanks for leading me in the right direction.

 

These will be library type files. I think I finally figured it out:

 

What I ended up doing is creating two rules.

 

First rule converted my Custom iProperties to Parameters and Updates the file. Because Inventor doesn't seem to like iParts and iLogic playing together, I had to create an event trigger to run the rule every time there was a parameter change (I didn't have any parameter changes so I created a dummy sketch with a dimension that changed per iPart child. This made it so every time I manually activated an iPart child it actually updated my extruded sign text.

 

	SIGNTEXT = iProperties.Value("Custom", "SIGNTEXT")
	iLogicVb.UpdateWhenDone = True


Second rule cycles through every iPart iteration and runs the first rule, while also updating and then Generating the file.

 

Sub Main
Check = MessageBox.Show("Loop through iPart factory and populated members, This will take a while. Are you sure?" _
, "Ilogic Instructions", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
If  Check = vbYes Then 
 	
	Dim oDoc As Document
	oDoc = ThisDoc.Document
	
    'Check if ODoc is a Part Document
	If oDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject  Then
	   'MessageBox.Show("This is a part file.", "iLogic")
		      
		'Set a reference to the component definition
		oDef = ThisApplication.ActiveEditDocument.ComponentDefinition

		'Make sure we have an iPart factory.
	    If oDef.IsiPartFactory  = False Then
	        MsgBox ("Chosen document is not a factory.", vbExclamation)
	        Exit Sub
	    End If
			
		' Set a reference to the factory.
		Dim oFactory As iPartFactory
		oFactory = oDef.iPartFactory

		'iPartF = oDef.iPartMember.ParentFactory
		'Get the number of rows in the factory.
		Dim iNumRows As Integer
		iNumRows = oFactory.TableRows.Count 
		 
		Dim iRow As Integer
		'Set iRow = First Member
		oStart = InputBox("Pick a Start Row", "Member Start Row#", 1)
		oEnd = InputBox("Pick an End Row", "Member End Row#", iNumRows)

		Try
			For iRow = oStart To oEnd
				'Use if this main rule is external
				iLogicVb.RunRule("convertiPropertytoParameter")
				oFactory.CreateMember(oRow)				

				'Change ipart Row
				iPart.ChangeRow("", iRow)
				
				'Use if memberfile name needed
				'MemberFileName = oFactory.FileNameColumn(iRow).Value
				'MessageBox.Show(MemberFileName, "Title")

				'[---Call external "function" or rule or do something---

				'[Select by UI the node of current member in order to bring up the message ipart has change contents,
				'If this is not used parameters will only apply to last member active
				'https://forums.autodesk.com/t5/inventor-customization/possible-to-check-all-members-of-factory-for-errors-using-ilogic/td-p/3863094

				Dim oErrorManager As ErrorManager
				   oErrorManager = ThisApplication.ErrorManager
				 
				Dim oTop As BrowserNode
				     oTop = oDoc.BrowserPanes("Model").TopNode
				   
				Dim bHasErrorOrWarning As Boolean
				'To skip without messages, this will not work for change of parameter
				'ThisApplication.SilentOperation = False
				   
			    ' Highlight the iPart table row 
			    oTop.BrowserNodes("Table").BrowserNodes.Item(iRow).DoSelect
		
			    ' Activate the iPart table row, this will trigger the "Do you want to change table contents accept yes to allow parameters to be saved to ipart member row. 
			    Dim oCommand As ControlDefinition
			    oCommand = ThisApplication.CommandManager.ControlDefinitions("PartComputeiPartRowCtxCmd")
			    oCommand.Execute
			
				 If oErrorManager.HasErrors Or oErrorManager.HasWarnings Then
				        MsgBox (oErrorManager.LastMessage, vbOKCancel)
				 End If
					 
					'Use if required
				'ThisDoc.Document.Rebuild() 
				'Create each member
'					Try	
'					 	Call oFactory.CreateMember
'					 Catch
'						MessageBox.Show("Error creating Member", "iLogic") 
'					 End Try
			Next
	
			Catch
			MessageBox.Show("Error Exiting", "iLogic")	
			End Try
			
			iLogicVb.UpdateWhenDone = True
			
				'open folder	
			'oFolder = ThisDoc.Path &"\" & ThisDoc.FileName(False)
			'Call Shell("explorer.exe" & " " & oFolder, vbNormalFocus)
		Else
		End If
	Else
	End If
End Sub

 

Thanks for your help!

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

Post to forums  

Autodesk Design & Make Report