How to change iAssembly row through iLogic

How to change iAssembly row through iLogic

kschaffroth1
Contributor Contributor
1,587 Views
5 Replies
Message 1 of 6

How to change iAssembly row through iLogic

kschaffroth1
Contributor
Contributor

Hello,

 

I have an iAssembly with 3 different variations that I would like to change through a user parameter, but in iLogic the function ChangeRow and FindRow I don't seem to work in this case because it is looking for an iPart specifically. 

 

Any ideas?

 

Thanks

0 Likes
Accepted solutions (1)
1,588 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

The ilogic snippet works for this. Either use  iPart or iAssembly. Ensure you stabilize the browser node  otherwise ilogic will not be able to find the file once the member has been changed. This is likely what is happening for you. 

Change Row iAssembly.PNG

 

https://www.cadlinecommunity.co.uk/hc/en-us/articles/202020161-Inventor-2014-iLogic-Stabilise-Browse...

https://forums.autodesk.com/t5/inventor-forum/ilogic-change-row/td-p/5118180

 

If you are wanting to dive into controlling the iassembly factory more there is the API help available online 

https://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-5804204C-FE9F-484C-80C0-83AB76824BEA

and also with your install. 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

kschaffroth1
Contributor
Contributor

Can you elaborate a little more on the second one with the iAssemblyMember.Row property and how I can use that? You have an assembly with iAssemblies within it, but I am looking to change the row on the iAssembly I am in at that time. Not within another assembly.

 

Thanks

0 Likes
Message 4 of 6

A.Acheson
Mentor
Mentor

It sound like you want to change the members within the iAssembly factory. The rule below does that and it also does it for an iPart factory as well. I have left in commenting to show you what can be done with the rule. If you are looking to change iProperties via the rule you will need additional pieces of code to get around system generating messages.

Here are a few links that help me generate the below. 

https://forums.autodesk.com/t5/inventor-customization/automate-idw-drawing-file-creation-for-all-ipa...
http://inventortrenches.blogspot.com/2013/03/determine-file-type-for-ilogic-rule.html

 

Sub Main
	Check = MessageBox.Show("Loop through factory 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
		
		If oDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then
			
			'Check if ODoc is a Part Document
		   '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
			
			'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 a Start Row", "Member Start Row#", iNumRows)
			
			If oStart = "" Then
				If 	oEnd = "" Then
					Exit Sub	
				End If
			End If
			
			For iRow = oStart To oEnd
				
				'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--
	
					'Use if required
				'ThisDoc.Document.Rebuild() 
				'Create each member
'					Try	
'					 	Call oFactory.CreateMember
'					 Catch
'						MessageBox.Show("Error creating Member", "iLogic") 
'					 End Try
				Next
				iLogicVb.UpdateWhenDone = True
				
					'open folder	
				'oFolder = ThisDoc.Path &"\" & ThisDoc.FileName(False)
				'Call Shell("explorer.exe" & " " & oFolder, vbNormalFocus)
			ElseIf oDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
				'Check if ODoc is a Part Document
			
			   'MessageBox.Show("This is a Assembly file.", "iLogic")
				      
				'Set a reference to the component definition
				oDef = ThisApplication.ActiveEditDocument.ComponentDefinition

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

				'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 a Start Row", "Member End Row#", iNumRows)
				
				If oStart = "" Then
					If 	oEnd = "" Then
						Exit Sub	
					End If
				End If
				
				For iRow = oStart To oEnd
					'Change iassembly Row
					iAssembly.ChangeRow("", iRow)
					
					'Use if memberfile name needed
					MemberFileName = oFactory.FileNameColumn(iRow).Value
					MessageBox.Show(MemberFileName, "Title")

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

				
		
						'Use if required
					'ThisDoc.Document.Rebuild() 
					'Create each member
	'					Try	
	'					 	Call oFactory.CreateMember
	'					 Catch
	'						MessageBox.Show("Error creating Member", "iLogic") 
	'					 End Try
				Next
				iLogicVb.UpdateWhenDone = True
					
						'open folder	
					'oFolder = ThisDoc.Path &"\" & ThisDoc.FileName(False)
					'Call Shell("explorer.exe" & " " & oFolder, vbNormalFocus)
					
			End If
	Else
	End If
End Sub

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 6

A.Acheson
Mentor
Mentor
Accepted solution

 

Previous Post

"Can you elaborate a little more on the second one with the iAssemblyMember.Row property and how I can use that? You have an assembly with iAssemblies within it, but I am looking to change the row on the iAssembly I am in at that time. Not within another assembly. "

 

The previous post I put up was more for processing  contents  of the factory file but in reality the snippet below is all that is needed to change the member factory file.

iPart.ChangeRow("", "Member Name")

Can you post a sample file showing the workflow your using , or screenshots. 

 

Change Row iAssembly Factory.PNG

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 6 of 6

kschaffroth1
Contributor
Contributor

That works! Thank you! Interesting how the first quotation marks have to be empty to change it, never would have thought of that. This will be very helpful. And I would show you what I am working on, however, it is on my computer at work and I am not at work until Monday. 

0 Likes