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: 

can i stop inventor form change it index ?

4 REPLIES 4
Reply
Message 1 of 5
Darkforce_the_ilogic_guy
150 Views, 4 Replies

can i stop inventor form change it index ?

Well I open the file in 2020 the soild index in on the left, If I open the file in 2024 the some same files index will change to the one on the right. Is there a way to stop Inventor 2024 from marking that change ? 

 

It break some of my ilogic that works on index / item

ThisDoc.Document.ComponentDefinition.SurfaceBodies.Item(11).Visible = False

 

 

Darkforce_the_ilogic_guy_1-1723552483147.png

 

4 REPLIES 4
Message 2 of 5

I'm not aware of a way to change the index. You could use the name instead of the index. For future projects it's probably best to rename the solids to something meaningful so it's easier to use.

Message 3 of 5

Not sure about stopping the program from reordering the index. It's hard to say without knowing your program/specifics to know what's causing that problem. However, I wrote something up that might help you. 

 

Similar to the other comment on this thread, when you have access to the names of the items you wish to use. It's more than likely to be best to just target that name. However, in the following Code, I'm doing something similar to reorder the items correctly. 

 

Sub Main()
	
	Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim AsCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
	Dim oTO As TransientObjects = ThisApplication.TransientObjects
	Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
	
	Dim ItemList As New List(Of String)
	
	Dim OrderedList As New List(Of String)
   
	
	
	'This is populating our list for the example.  
	For i As Integer = 1 To 15
		ItemList.Add("Solid" & i)
		Logger.Info("Original List: " & ItemList.Item(i - 1).ToString)
	Next

	
	'In this situation we can use that number value inside the names of the solids to find the order in which they need to be placed in the new list. 
	Dim OrderingIndex As Integer = 1
	
	For Each oString As String In ItemList
		If oString.Contains(OrderingIndex) Then 
			OrderedList.Add(oString)
			Logger.Info("Ordered list: " & OrderedList(OrderingIndex - 1).ToString)
		End If 
		OrderingIndex = OrderingIndex + 1
	Next
	

End Sub

 

You may need to change the item lists to collections and target things a bit differently. However, this should place all the items from the "itemlist" into the "OrderedList" in the correct order. You can see that It was already ordered in my first list. Yet, the last for each loop places them by finding the number inside the string while checking what number that item is based off the number in it's name. Instead of lists being used, you need to target the collections the objects will be contained within. 

 

 

Jpfeifer5TC7R_0-1723639863852.png

 

Message 4 of 5

As it write in the post.  the company have just update form Autodesk inventor 2020  to Autodesk Inventor 2024.  But the item index are not the same even when the file is the same. the change seems almost random

 

 

and now the problem is that we have to open and rewrite the ilogic code  all 520 files.. and that is a lot of work. 

 

the easy thing for me would be if I have get autodesk inventor to keep the item number.  but I fear I am force to rewrite them all .. I use this code to fil the old  index number . So i can rewrite the code without having to understand all detalje of the model to find the right one 

'define the active document
partDoc = ThisDoc.Document
Dim solid As SurfaceBody
Dim i As Integer

Dim Name_of_solid As String
Dim List_of_solids As String
List_of_solids = "Solid bodies list: "

i = 1

For Each solid In ThisDoc.Document.ComponentDefinition.SurfaceBodies
	Name_of_solid = solid.Name
	List_of_solids = List_of_solids & vbCrLf & i & ": " &  Name_of_solid

i = i + 1
Next
	
'MessageBox.Show(List_of_solids, "Solid bodies found")
myparam = InputBox(List_of_solids, "Solid bodies found", List_of_solids)

 

 

 

Message 5 of 5

If your problem is the fact that you have to make the same change to ilogic code in a lot of files you may want to take a look at this tool: iLogic Rule Batch Tool | Inventor | Autodesk App Store

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

Post to forums  

Autodesk Design & Make Report