Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Script Error Origin #MEL

1 REPLY 1
Reply
Message 1 of 2
jayantbhatt07
441 Views, 1 Reply

Script Error Origin #MEL

Hi, I'm working on a free Nut_Bolt script but I'm getting an error. Let's say I'm Importing the Bolt_01  it's snapping to the selected face but again when I run this script on a new selected face it's taking back Bolt_01 to the origin. It shouldn't happen like that. For more refer video.

  1. {
  2. // create a window
  3. window -title "jay" -menuBar true -w 220 -h 200 "";
  4. // define the layout of controls added
  5. // to the window.
  6. columnLayout;
  7. // create a collapsible frame layout
  8. frameLayout -collapsable true -label "Nuts";
  9.  
  10. // add the other controls
  11. flowLayout -columnSpacing 1 -w 220 -h 30;
  12. symbolButton -image "commandButton.png" -command "sample_Proc";
  13.  
  14. setParent ..;
  15.  
  16.  
  17. // show the window we last created
  18. showWindow;;
  19. }
  20.  
  21.  
  22.  
  23. proc sample_Proc()
  24. {
  25. string $sel_faces[] = `ls -sl `;
  26. file -import "E:/Bolt_01.ma";
  27. select $sel_faces[0] "Bolt_01";
  28. float $rsScale = size($sel_faces);
  29. scale -r $rsScale $rsScale $rsScale "Bolt_01";
  30. string $rspointOnPolyConstraint[] = `pointOnPolyConstraint -offset 0 0 0 -weight 1 `;
  31. delete $rspointOnPolyConstraint;
  32. rename "nut_01" "nutPlaced_01";
  33. makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1;
  34. }

1 REPLY 1
Message 2 of 2
haggi
in reply to: jayantbhatt07

Well, as much as I can see, you always use the very first bolt

select $sel_faces[0] "Bolt_01";

And every time a new Bolt is imported it gets a new name. So what happens is: The new Bolt is imported and placed in world center, then the very first "Bolt_01" is snapped to the selected face. I'm not sure, but I think the import command offers a way to get the imported node names which can be used to get the correct name of the imported bolt.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report