Attach mesh objs by name with numbering - Revit Import

Hi guys,
I'm often dealing with imported Revit files.
They contain more than 20k objects.
I need to attach them, by name, but they have numbering at the end, CF Attached file.

Would it be possible to attach the objects that have the exact same name but disregarding the last numbering bit? At least it's using the brackets so maybe we could use that to exclude from the name?

It has to stay a editable mesh and not be converted to poly as this leads sometimes to bad geometry.

Thanks a lot for your help.
Cheers
Stan

AttachmentSize
snag-0115.png134.76 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ruebenad's picture

Beginner Question

Hi

I save this code as a *.ms file and tried to run it as a script but it did not collapse the mesh...what am I doing wrong?

Rueben

ruebenad's picture

How do I use these scripts?

Hi

Obviously a newbie question here, but these lines of code/scripts how do I make them work?

I tried to copy the code into the max's "new script" save it out as an *.mcr, then tried and run the script and nothing happens.

Regards Rueben

stanley_asbeek's picture

Hey mate, just got a little

Hey mate, just got a little error.

Thanks for your help, really appreciated!
Stan

AttachmentSize
snag-0111.png 17.7 KB
pixamoon's picture

`

ah, true, it did not work for names with spaces
this one should work for all kind of names:

(
	local basenames = #()
	local filterN = " ["
	for o in geometry do (
		a = filterstring o.name filterN
		if a.count > 1 then appendifunique basenames a[1]
	)
 
	for n in basenames do (
		a = (execute("$'"+n+"*'")) as array
		if a.count > 1 and classof a[1] == Editable_Mesh then (
			a[1].name = (filterstring a[1].name filterN)[1]
			for i = 2 to a.count do attach a[1] a[i]
			)
	)
)
stanley_asbeek's picture

Cheers mate, seems to work,

Cheers mate, seems to work, although it eats up my ram :-)

AttachmentSize
snag-0129.png 7.85 KB
pixamoon's picture

`

wow, did you try to save and open it again ?
if yes, and still the same ram usage than maybe new objects are to heavy

if was caused by operations in script you can try to use just: gc()

or

(
	local basenames = #()
	local filterN = " ["
	for o in geometry do (
		a = filterstring o.name filterN
		if a.count > 1 then appendifunique basenames a[1]
	)
 
	for n in basenames do (
		local a = (execute("$'"+n+"*'")) as array
		if a.count > 1 and classof a[1] == Editable_Mesh then (
			a[1].name = (filterstring a[1].name filterN)[1]
			for i = 2 to a.count do attach a[1] a[i]
			)
		a = undefined
		free a
		gc()
	)
	basenames = undefined
	free basenames
	gc()
)
miauu's picture

.

Linear attach will be versy slow. This thread can be used to improve the attach algorythm and to speed up the time for attaching.

stanley_asbeek's picture

Hey guys, I'm facing the same

Hey guys,
I'm facing the same issue again.
Got a scene with 150k objects and only 450k poly but ram goes through the roof and crashs max.

Any help would be appreciated.

Thanks
Stan

pixamoon's picture

`

hi, try this one:

(
	local basenames = #()
	local filterN = " ["
	for o in geometry do (
		a = filterstring o.name filterN
		if a.count > 1 then appendifunique basenames a[1]
	)
 
	for n in basenames do (
		local str = stringStream ""
		format "a = $%*" n to:str
		execute (str as string)
		a = a as array
		if a.count > 1 then (
			a[1].name = (filterstring a[1].name filterN)[1]
			for i = 2 to a.count do attach a[1] a[i]
			)
	)
)
ruebenad's picture

Beginner Question

Hi

I save this code as a *.ms file and tried to run it as a script but it did not collapse the mesh...what am I doing wrong?

Rueben

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.