Notifications
Clear all

[Closed] How to add new objects in cloth modifier within scripts?

The cloth modifier may collect many objects into one cloth simulation.
other than picking up objects into one existing cloth modifier, it will create another cloth independantly.
I am wonder that there are not existing method for picking objects into an existing cloth simulation, when coding scrits.
Is there any efficient methods can do this task?

4 Replies

To add to a existing cloth sim modifier, all you need to do is to add the same modifier to the object. For example if you have a cloth sim modifier added to a $Cloth01 and you want to add $Cloth02 to the same sim then do this:

addModifier $Cloth02 ($Cloth01.modifiers[#Cloth])--- This adds Cloth02 to the same sim
$Cloth02.modifiers[1].setObjectType $Cloth02 2 true --  This sets the Cloth02 as a Cloth object

if u want to add Table as a Collision object first add the modifier and then change the 2 with 1 i.e.
0 – Inactive
1 – Collision
2 – Cloth


addModifier $Table ($Cloth01.modifiers[#Cloth])
$Table.modifiers[1].setObjectType $Table 1 true

For more info see Cloth Modifier in MXS help.

2 Replies
(@zionman)
Joined: 1 year ago

Posts: 0

Thanks a lot, that’s exactly needed.
The problem follows is that:
I have two piece of cloth add under the same cloth modifier, is there any automatic method to select vertice group, to make these two piece seam togather.
That is, select a region of vertice from $cloth1( as if we draw a rectangle on the view to select the vertices) and make it as group, and assign cloth to $cloth2

(@zionman)
Joined: 1 year ago

Posts: 0

The problem should state more clearly.
As in the scripts, I need to select vertex bounded by projection onto the current view of two 3d points, say point1 and point2.
we may use the following code draw one rectangle quoting the range

pt1=gw.transPoint(point1)
pt2=gw.transPoint(point2) 

we can use

Nodes=boxPickNode(box2[pt1.x,pt1.y][pt2.x,pt2.y])

to automaticaly select all objects enclosed. but, there seems not any equivalence for automatically selecting the bounded vertexes.

i can’t find any method to create a group using maxscript, i think you need to manually create a group. After creating a group u can assign cloth to cloth02

 $Cloth01.modifiers[1].makeConstraint "Group01" "Cloth" $Cloth02