Jump to content

Change Part Order


---
 Share

Recommended Posts

Hello to all,

is there a way to change the part number order? I have a multipart project, but I have made the part not in the correct order and I have to change the order for using a script. This is the result:

CopyQ.UvIqlo.thumb.png.1c421ed97c66394dcacc7c2ae23af41a.png

Inj this case I have to change the index of P3_12016927 and P6_12016930 becuse they are not in the correct order. The right order is as seen in the explorer (on the upper-left side of the image). Is it possible to do it?

 

Thank you in advance!

Link to comment
Share on other sites

what is your ultimate intention ? the order in the explorer is alphabetical.  the list of parts by code may be by order created , I havent looked into that detail.  

Link to comment
Share on other sites

Hi,

the order of elements/parts/alignment from a scripting point approach is arbitrary. Usually it is internally ordered via the creation timestamps but you can't rely on that. If you want to ensure a specified part order in your scripting you have to create your own list and iterate over your own list. e.g as an sorted directory.

Regards,

Bernd

Link to comment
Share on other sites

Please sign in to view this quote.

My intention is to automate the substitution of the mesh into every single part. But if the part index is not the same as in the explorer order, I can't do it. I think I have to do again the original template create the parts in order. I don't think there are other solutions that I am able to do.

Link to comment
Share on other sites

Please sign in to view this quote.

Hi and thanx for the response!

I found a solution thanx to you!

This is the code I used:

# -*- coding: utf-8 -*-

import gom

part_lst=[]
for n in range (len(gom.app.project.parts)):
	part=gom.app.project.parts[n].part
	part_lst.append(part)
print (part_lst)
part_lst.sort()
print (part_lst)
run_init=-1
for n in part_lst:
	run_init += 1
	print (run_init)
	gom.script.part.add_elements_to_part (
		elements=[gom.app.project.clipboard.actual_elements[0]], 
		import_mode='replace_elements', 
		part=n)

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...