ytsejam
Hi all and Hi Peter.
I know this is a question similar to a newbie question, but:

I wish to have the scatter node in one click, similar to interface that load distribuited object and surface for distribution, but in one interface without the more connections.
It's only for fast workflow.
Thanks

Dario

Reply 0 0
pshipkov
Many of us are thinking about the same. Not only about the scatter node but in general - to automate the most common workflows.
I don't have the time for this right now, but one day.
You are more than welcome to contribute scriptie or something that does it for you.

Reply 0 0
pechart
I made a small script for myself wich just builds the nodes (scatter, shatter, dummypoly), makes the needed connections and sets some attrs. Really no big thing and far from perfect, but maybe still usefull for you.
Just copy to a Python-Tab in the script editor and execute with a polyobject selected.

#start of script
#--shatters the currently selected polyobject with soup (needs to be installed)


import pymel.core as pm


myShape = pm.ls(selection=True)[0].getShape()

myShapeName = myShape.name()


myScatterName = ('SCATTER_' +myShapeName)

myShatterName = ('SHATTER_' +myShapeName)


myScatter = pm.createNode('scatter', n = myScatterName)

myShatter = pm.createNode('shatter', n = myShatterName)


myShape.worldMesh >> myScatter.inGeometry

myShape.worldMatrix >> myScatter.inWorldMatrix

myScatter.outPositionPP >> myShatter.inPositionPP

myScatter.outGeometry >> myShatter.inGeometry


myShatter.maxCutsPerPoint.set(12)

myShatter.distance.set(0.001)

myScatter.tolerance.set(10)


newGeoShapeName = ('shattered_' +myShapeName)

newGeoShape = pm.polyCube(n = newGeoShapeName)[0].getShape()

myShatter.outGeometry >> newGeoShape.inMesh


pm.select(newGeoShape)

pm.runtime.HideUnselectedObjects()

pm.select(myScatter)

print 'Object shattered, turn on Auto Evaluate on Shatter Node to show result.'

       



#end of script




       





Reply 0 0
pshipkov
Very nice man, i may include that (or something based on it) in the next build as a "wrench" shelf button tool.
Reply 0 0
saisimha
hii.
I am Trying to make a UI for scatter node..(using QT designer/Creator) and python.. i had some problem with my python code..

# Error: IndentationError: unexpected indent #

Any help would be gr8..

Note:Its just basic(noting wow)... i am not a advanced programmer.. just started  learning coding :)



Reply 0 0
pechart
An indentation fault is what it says ;) Most likely there's a tab or whitespace in the code where it shouldn't be.

Python relies on indents (=Tabs)  when doing stuff like looping, if/else checking,...

So, this means that you have to put an indent (4 whitespaces) at those places. Mayas script editor sometimes screws this. Also, when copying code from internet forums the code can get messed up. Try to use an editor that shows you the indentations/tabs. I suggest Komodo Edit, but others are good, too. Maybe notepadd++ does it, i don't know.

Reply 0 0
saisimha
Thank you pechart .. it makes sense now :)
but i had some
# Warning: 'pPlaneShape1.worldMesh[0]' is already connected to 'scatterShape1.inGeometry'. #

# Error: RuntimeError: Maya command error #



this is the code i run


    mc.connectAttr(ssTerainShape[0]+".worldMesh[0]", ssScatter[1]+".inGeometry", f=True )
    mc.connectAttr(ssTerain[0]+".worldMatrix[0]", ssScatter[1]+".inWorldMatrix", f=True )
   

How to force python to reconnect !!



Reply 0 0
JeremyR
Just one comment if I may... I would get rid of the load plugin lines of code because linux and mac users will get an error. You could always include some OS check first I guess and have a separate line for each one, Im not sure what code you would use for that.
Reply 0 0
pechart
Comments are welcome, of course!

Maybe I find some time to work it over, but I'm pretty busy right now. The script was only a little helper for an actual project we're doing. Feel free to modify as you like ;)

EDIT: And the plugin loading is studio specific, of course, just throw it away.
Reply 0 0
pshipkov
About the plug-in load - you can use the qt=True flag and it will be fine even the plugin is already loaded.
Reply 0 0
saisimha
how to set values to point node wieght position rasius color !! etc
 using python

// POINT WEIGHT

$W=rand(0,5);


!!



Reply 0 0
pshipkov
import maya.cmds as mc

mc.setAttr("point1.weight", "$W=rand(0,5);", dt="string")

btw, i am not sure what the attribute name holding the string is right now, check it in the connection editor for example.

Reply 0 0
saisimha

mc.setAttr("point1.weight", "$W=rand(0,5);", dt="string")

# Error: TypeError: Invalid flag 'dt' #

:S

Reply 0 0
saisimha
when i try this
mc.setAttr("point1.weight", "$W=rand(0,5);", type="string")

# Error: RuntimeError: setAttr: No object matches name: point1.weight #

:S :S



Reply 0 0
saisimha
mc.setAttr(ssPoint+".stringWeight", "$W=rand(0,5);", type="string")



works at last :)

Reply 0 0
Reply