deleting a utility node with mel

ronviers
Enthusiast
Enthusiast

deleting a utility node with mel

ronviers
Enthusiast
Enthusiast

If i run this script without the 'delete' command it works fine, the poci node remains selected and can be delete manually. If i run the same script with the delete command it does not execute. Can anyone explain why?

 

thanks:)

 

select `createNode pointOnCurveInfo`;
setAttr ".pr" .5;
connectAttr -f path_AlembicNode.outNCurveGrp[0] ".ic";
connectAttr -f ".p" entanglement:entanglement_ctl.translate;
connectAttr -f ".n" entanglement:entanglement_ctl.rotate;
delete;

0 Likes
Reply
Accepted solutions (1)
1,244 Views
6 Replies
Replies (6)

tkaap2
Autodesk
Autodesk

This runs for me with and without the call to delete.  I've tried to create a dummy scene that should mimic the basics of your scenario (without Alembic).  Can you please try this and verify that it works for you?  I'd also suggesting adding a line of:

print `ls -sl`

Just before your call to delete to check what Maya believes to be selected.

 

file -f -new;
namespace -addNamespace "entanglement";
namespace -set "entanglement";
string $loc[] = `spaceLocator -n entanglement_curveLocation`;
namespace -set ":";

string $curve = `curve -p 0 0 0 -p 3 5 6 -p 5 6 7 -p 9 9 9`;
string $node = `createNode pointOnCurveInfo`;
select $node;
setAttr ".pr" 0.5;
connectAttr -f ($curve +".worldSpace[0]") ".ic";
connectAttr -f ".p" ($loc[0]+".translate");
connectAttr -f ".n" ($loc[0]+".rotate");
delete;

ronviers
Enthusiast
Enthusiast

Hi ktaap2,

Thank you for taking time to look into my problem:) In the following examples the namespace and alembic variables have been eliminated. The first example is your method. Both execute fine without the delete command but neither do when the delete command is added. That is, they both create the curve and locator but fail to move the locator into place. Do either of these work for you?

(using maya v2019.2)

 

string $loc[] = `spaceLocator -n ntanglement_curveLocation`;
string $curve = `curve -p 0 0 0 -p 3 5 6 -p 5 6 7 -p 9 9 9`;
string $node = `createNode pointOnCurveInfo`;
select $node; setAttr ".pr" 0.5;
connectAttr -f ($curve +".worldSpace[0]") ".ic";
connectAttr -f ".p" ($loc[0]+".translate");
connectAttr -f ".n" ($loc[0]+".rotate");
delete $node;

-------------------------------

circle -c 0 5 0;
spaceLocator;
createNode pointOnCurveInfo;
setAttr ".pr" 0.5;
connectAttr -f nurbsCircleShape1.worldSpace[0] ".ic";
connectAttr -f ".p" locator1.translate;
connectAttr -f ".n" locator1.rotate;
delete;

 

0 Likes

tkaap2
Autodesk
Autodesk
Accepted solution

The problem in these scripts is that the pointOnCurveInfo node is getting deleted before Maya ever triggers an evaluation through it, so the locator never gets moved.  Try adding a call to `refresh` or `getAttr(locator1.translate)` to trigger an evaluation.  When I do that, the locator gets moved onto the curve, then the pointOnCurveInfo node is deleted.

 

circle -c 0 5 0;
spaceLocator;
createNode pointOnCurveInfo;
setAttr ".pr" 0.5;
connectAttr -f nurbsCircleShape1.worldSpace[0] ".ic";
connectAttr -f ".p" locator1.translate;
connectAttr -f ".n" locator1.rotate;
refresh; // <--- The draw will force Maya to do an evaluation to move the locator
delete;

If this is close to your real workflow, and if you really just want a node moved one time to a point on a curve, is the pointOnCurve command more convenient for you?  It does exactly what you're doing here -- creates the node, builds the connections, returns the queried values, then (optionally) deletes the node.  It just might be convenient in your larger script.

ronviers
Enthusiast
Enthusiast

ooo pointOnCurve command, i like that. It didn't occur to me to check for a command.

Thank you for helping me understand the problem and for a better solution:)

0 Likes

ronviers
Enthusiast
Enthusiast

quick followup and fyi:
Just noticed the 'pointOnCurve' command leaves orphaned pointOnCurveInfo nodes attached to the curves, and with my limited knowledge of mel there appears to be no way to capture the names for deletion - as there is with the node creation method. The upshot is that the first workaround, using 'refresh', is preferable for my purposes.

 

thanks:)

0 Likes

tkaap2
Autodesk
Autodesk

Hmm.  Fair enough.  Go with the workflow that's working for you.  It definitely shouldn't leave nodes hanging around, but there are a handful of reasons that can happen.  You don't happen to be calling pointOnCurve with the -ch flag enabled, do you?

 

There's no way to capture that node name in MEL, so you'd have to walk the graph to see what is connected using the `listConnections` command.  So that's an option for the future if a change needs to happen.

// set up curve
circle -c 0 5 0;
// force pointOnCurve to leave its constructionHistory in place
pointOnCurve -constructionHistory 1 -pr 0.5 nurbsCircle1;

string $connectedPlugs[] = `listConnections -plugs 1 nurbsCircleShape1`;
print $connectedPlugs;

string $pOC_plugs2[] = `listConnections -plugs 1 pointOnCurveInfo1.inputCurve`;
print $pOC_plugs2