![]() ![]() In your case you won't have the option of creating the nodes directly under your top-level group - you'll have to rename them after creation and parenting. So, for your example you'll want to create your top-level groups with the # suffix so they can predictably get suffixes, and then manually increment the names of the children as you create them. I've manually incremented the names because I'm certain there will be no clashes under top_node_# but that's only reliable if you know for sure that nothing at the same hierarchy level will have the same name stem. Running this twice will produce top_node_1 and top_node_2 but they'll both have children named child1 through child10. # calling createNode with 'p=' makes the new items as childrenĬmds.createNode('transform', n= 'child%i' % n, p=topnode) To avoid name clashes you can use a namespace or a top level group: topnode = cmds.createNode('transform', n= 'top_node_#') Running the above code twice would generate more transforms named example_11 through example_20. However maya won't let you have two items at the same level of the hierarchy with the same name, so it may decide to change your numbering scheme to avoid name clashes. When you create an object in maya, appending # to the name will automatically increment the name : examples = It would be great if I could do the same with the position so that the strand continuously grows each time the script is run. I would like to make the names relative so that if the object exists it will create a new object based on what already exists (example strandLName 20 ++). I have 3 objects that have been grouped and that group is then iterated another 19 times to create a spiral DNA strand. ![]() Nucleotide = mc.parent(strandL, nucleo, strandR, grp) Grp = mc.group(n=strandLName + 'NULL', em=1) ![]() Mc.setAttr(strandRName + '.translateX', 10) StrandR,strandHistory = mc.polySphere(name=strandRName, ch=1) Mc.setAttr(nucleoName + '.translateX', 5) Nucleo,nucleoHistory = mc.pol圜ylinder(name=nucleoName, ch=1) StrandL,strandHistory = mc.polySphere(name=strandLName, ch=1) If I run it once it works, but the second time I get: Error: setAttr: Not enough data was provided. ![]() Trying to make a script I created be able to run multiple times. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |