Notifications
Clear all

[Closed] first script very simple…but wrong

Hi, I’m a newbie with max script. I’m getting closer out of necessity, and here I report my first script.
is very simple and the goal is to convert a selection of object in body_object.

The problem is that it works with only one selected object, wrong … where?

SCRIPT:

select geometry
for i = 1 to selection.count do
macros.run “Body Objects” “Body_Object”

10 Replies

to answer your question people has to know what “Body_Object” macros is.

Body object is a native geometry of 3ds max:
create panel > geometry > body objects > body object

1 Reply
(@ecarter)
Joined: 11 months ago

Posts: 0

I can’t find that obj, maybe you are using some extra plugins, because there is no body object under the geometry category.

can you give us more information?

Now i’m working with 3ds max design 2011 and 2012…no external plugin…

this is a screencapture…

ok. i found it. it’s in 2012.
so the macros starts Body_Object creation. How do you want to use it with multiple selection?

Ok!
I’ve many geometries and i’d like to convert these to body object for control all parameters of visualisation in viewport and rendering in the same time.
But with the standard command on 3ds max I manage an object at a time, and if i’ve hundreds of objects…
So I’m searching to create a script with a loop!

Now it start, but only with one object selected.

Maybe… (‘hit-in-the-dark’)

(
	nodes = geometry as array
	max select none
	for n in nodes do
	(
		select n
		if okToCreate Body_Object do
		StartObjectCreation Body_Object
	)
	max modify mode
)

Note: Body_Object class is new in Max 2011,
I’m no max 2009 so can’t test this,
but lets hope its closer (:

2 Replies
(@kodo)
Joined: 11 months ago

Posts: 0

Thank’s!
I’ve try your solution…but thisi is the result…

– Error occurred in anonymous codeblock; filename: ; position: 176; line: 11
– Syntax error: at ), expected <factor>
– In line: )

(@denist)
Joined: 11 months ago

Posts: 0

Great! Panayot… it’s exactly as mine but quicker done!


(
	objs = for obj in (selection as array) where iskindof obj GeometryClass collect
	(
		select obj
		if not (okToCreate Body_Object) then dontcollect
		else
		(
			StartObjectCreation Body_Object
			obj
		)
	)
	clearselection()
	select objs
)

both work!!!
Thank’s very much!!!
Now I’ll use your solution, and study.