How to make script where applys fn() or script on several selected objects?

Hi frends!
Forexample is not works:

(
for obj in (selection as array) do
	(
		PolyToolsSelect.NumericEdge false
		obj.EditablePoly.ConvertSelection #Border #Vertex
		obj.weldThreshold = 0.001
		obj.EditablePoly.weldFlaggedVertices ()
		subobjectLevel = 3
	)
)

This script is works only with single object
Please help.
Thanks.

Comments

Comment viewing options

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

Thanks guys for answers

Thanks guys for answers

Nik's picture

here's the solution

(
for obj in (selection as array) do
	(
                select obj
		PolyToolsSelect.NumericEdge false
		obj.EditablePoly.ConvertSelection #Border #Vertex
		obj.weldThreshold = 0.001
		obj.EditablePoly.weldFlaggedVertices ()
		subobjectLevel = 3
	)
)
barigazy's picture

...

Do you know that this is "worst case scenario" solution.
Come on man, you can do this better I'm sure. :)

barigazy

barigazy's picture

...

Anyway ...

fn weldBorderVerts objs thresh:.001 = if objs.count != 0 do
(
	local moOpenEdges = meshop.getOpenEdges, poOpenEdges = polyop.getOpenEdges
	local moVertByEdge = meshop.getVertsUsingEdge, poVertByEdge = polyop.getVertsUsingEdge
	local moWeldVerts = meshop.weldVertsByThreshold, poWeldVerts = polyop.weldVertsByThreshold
	max create mode
	with redraw off for o in objs do
	(
		case classof o of
		(
			(editable_poly):
			(
				o.weldThreshold = thresh
				if not (edgelist = poOpenEdges o).isEmpty do (poWeldVerts o (poVertByEdge o edgelist))
			)
			(editable_mesh): (if not (edgelist = moOpenEdges o).isEmpty do (moWeldVerts o (moVertByEdge o edgelist) thresh))
		)
	)
)
weldBorderVerts selection

barigazy

miauu's picture

.

Now add few more lines for Editable Poly objects, so the weld threshold to be restored when te function finish its job. :)

barigazy's picture

...

Hey Kostadin, how are you?

barigazy

barigazy's picture

...

fn weldBorderVerts objs thresh:.001 = if objs.count != 0 do
(
	local moOpenEdges = meshop.getOpenEdges, poOpenEdges = polyop.getOpenEdges
	local moVertByEdge = meshop.getVertsUsingEdge, poVertByEdge = polyop.getVertsUsingEdge
	local moWeldVerts = meshop.weldVertsByThreshold, poWeldVerts = polyop.weldVertsByThreshold
	max create mode
	with redraw off for o in objs do
	(
		case classof o of
		(
			(editable_poly):
			(
				oldthresh = o.weldThreshold
				o.weldThreshold = thresh
				if not (edgelist = poOpenEdges o).isEmpty do (poWeldVerts o (poVertByEdge o edgelist))
				o.weldThreshold = oldthresh
			)
			(editable_mesh): (if not (edgelist = moOpenEdges o).isEmpty do (moWeldVerts o (moVertByEdge o edgelist) thresh))
		)
	)
)
weldBorderVerts selection

barigazy

miauu's picture

Busy. :) I hope you are

Busy. :)
I hope you are well.

Comment viewing options

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