View Full Version : getting the exact coordinates!
abdelouahabb 03-31-2010, 09:24 PM hi,
how to get the values in the coordinates manager, because it gives the exact coordinates of anything selected, edges, points, polygon...
so the goal of this is to make possible to add any joint or null object to any part of the object! because selecting the edge then making Conversion->Convert to null, will get all the object position, and the tip is to use edge mode, then Edge to Spline, then Axis Center to get the approximative position, (for polygon selection, the tip is simple, just select the desired polygon, then with Shift or Ctrl key (i think the relation is in the Vertex map...., then by holding one of those keys, clic on the Edge Mode, you'll get the surrounding edges, then go to Edge to spline, then use Axis center)....
but if it is possible to get the coordinates manager values, it will be possible to make it easier with a script?
:curious:
|
|
Scott Ayers
03-31-2010, 09:57 PM
I agree that it would be very handy to have scripting access the coordinates pallet.
It sure would make some things a lot easier.
I think the only way to currently do this kind of thing is to be a bit of a computer nerd and manually manipulate the matrix of the objects. Like this: //This script will create joints only on the selected points of the currently selected object
//Make sure the object selected is a polygon object. Not a primitive object!
var obj = doc->GetActiveObject(); //Gets the selected object
if(!obj)return; //Ends the script if nothing is selected
var pntsel = op->GetPointSelection();
var i;
for(i=0; i<obj->GetPointCount(); i++)
{
if(pntsel->IsSelected(i)) //Checks if any points are selected
{
var p = op->GetPoint(i); //Assign a variable to the points
CallCommand(1019362); //Create a Joint Object for each selected vertice
var n = doc->GetActiveObject();//Grab the Joints
n->SetPosition(vector(p.x,p.y,p.z)); //Place them on the selected verts
n->Message(MSG_UPDATE); //Update the changes
}
}
return 0; //End script
-ScottA
abdelouahabb
04-01-2010, 03:08 PM
thank you scott
yes, really it will be very helpful to make such this operation, i've tried to convert a point to joint but sadly it takes the position of the whole object (the axis object) and not the point or edge or polygon object (their axis)
so in the SDK i've searched how to get only the axis coordinates but dident really understood what it said :surprised
thanks again for the script :D
abdelouahabb
04-01-2010, 09:27 PM
hi
i've made this script as a file with icon, i've added a "add null object" in addition to the joint object.
thanks again scott :thumbsup:
abdelouahabb
04-02-2010, 02:58 PM
oups!
seems that there is a small problem with the script; it only gives the coordinates of the "initialised" object, so if you move the object, the null and joint will be added to the previous initialised position :argh:
i've tried to do something but it seems not to work, it gives in console some errors like "too few parameters" or "lot of parameters" or "incompatible values " :surprised
Scott Ayers
04-02-2010, 07:58 PM
Coffee has a bunch of ways to handle updating when an object is changed. And I'm afraid I'm still a bit lost on many of them.
I tried all of the various incarnations of the Message update function and none of them worked.
Hopefully someone with more experience will come along and have an answer for you.
-ScottA
rui_mac
04-02-2010, 10:33 PM
Change the JOIN2NULL script to:
//This script will create joints only on the selected points of the currently selected object
var obj = doc->GetActiveObject(); //Gets the selected object
if(!obj)return; //Ends the script if nothing is selected
var mat=obj->GetMg();
var pntsel = op->GetPointSelection();
var i;
for(i=0; i<obj->GetPointCount(); i++)
{
if(pntsel->IsSelected(i)) //Checks if any points are selected
{
var p = mat->GetMulP(op->GetPoint(i)); //Assign a variable to the points
CallCommand(1019362); //Create a Joint Object for each selected vertice
var n = doc->GetActiveObject();//Grab the Joints
n->SetPosition(vector(p.x,p.y,p.z)); //Place them on the selected verts
n->Message(MSG_UPDATE); //Update the changes
}
}
return 0; //End script
And the POINT2NULL to:
//This script will create joints only on the selected points of the currently selected object
var obj = doc->GetActiveObject(); //Gets the selected object
if(!obj)return; //Ends the script if nothing is selected
var mat=obj->GetMg();
var pntsel = op->GetPointSelection();
var i;
for(i=0; i<obj->GetPointCount(); i++)
{
if(pntsel->IsSelected(i)) //Checks if any points are selected
{
var p = mat->GetMulP(op->GetPoint(i)); //Assign a variable to the points
CallCommand(5140); //Create a Null Object for each selected vertice
var n = doc->GetActiveObject();//Grab the Null
n->SetPosition(vector(p.x,p.y,p.z)); //Place it on the selected verts
n->Message(MSG_UPDATE); //Update the changes
}
}
return 0; //End script
Also, you may want to change the Menu State code of both scripts to:
ENABLE=False;
if(op)
{
if(op->GetType()!=5100 && op->GetType()!=5101) return;
var pointc=op->GetPointSelection();
if(pointc==nil) return;
var i;
for(i=0;i<op->GetPointCount();i++) if(pointc->IsSelected(i)) ENABLE=True;
}
This will make the menu item of the scripts will only get enabled if a polygonal or editable spline object with at least one point selected is active.
Rui Batista
Scott Ayers
04-03-2010, 02:20 PM
Is there some way to update the vertice's positions rather than using a global matrix?
Refreshing and re-initializing things like vertice positions after they have been moved is something I'm still not very clear on how to handle.
-ScottA
abdelouahabb
04-03-2010, 04:52 PM
really big thanks Rui for the script!! it will be really a useful one :bounce:
i've tried to make a cheat with n->SetPosition(vector(p.x,p.y,p.z)); i said maybe i can do something with n->GetPosition(vector(p.x,p.y,p.z)); but it dident work :D
thanks again scott :)
NB: the script can be done with a tip, using Mograph of course :rolleyes:
to do this, just select the point, then save the selection (set selection), then add a cloner, choose object as mode, then make the object selected as the cloner, then make the vertex mode and assign the selected points, now, when using null object, and after converting to editable convert the cloner to lot of objects (nulls) it may make some problems, the solution is just to replace th null with an instance, now it will work, and the good thing with mograph that it will also update the normal of the nulls added (i think this is what the global matrix do) :D
and...thanks again for the help :scream:
rui_mac
04-03-2010, 07:05 PM
To be able to access deformed vertexes of an object, whe have to perform an internal "Current State to Object". To make that in COFFEE, any selected object will become deselected. It is impossible to create a clone of the object and operate just on that clone, in COFFEE. The best way to access deformed points is to use Xpresso or MoGraph.
Rui Batista
Scott Ayers
04-03-2010, 08:27 PM
Interesting.
I wasn't thinking of it as deforming. But now that you say that, I guess that does make sense.
I can see why using a global matrix is so important for something like this.
It seems kind of a shame to me that there's no way to re-initialize things.
But as long as using a global matrix works I guess it doesn't matter too much.
Thanks rui,
-ScottA
abdelouahabb
04-03-2010, 08:56 PM
!
understanding the cinema 4d logic! mmmmmmmmmmmmmmmm! :surprised
well, here is another script, maybe it will be helpful, it use the same thing as Split function, but instead of (copy and paste) here is "cut and paste + rename)...
var miaw = doc ->GetActiveObject();
doc->AddUndo(UNDO_OBJECT, miaw);// to have Undo
CallCommand(14046); //Split
CallCommand(12109); // Delete
var haw = miaw->GetNext();
haw = haw->SetName("MiawClone"); //Renames the resulted object to MiawClone :D
hope this helps. :p
rui_mac
04-04-2010, 12:40 AM
Well, I assumed that you two wanted to be able to access points of polygonal objects once they are deformed. But if the polygonal object simply changes position, scale or rotation, the matrix method is all that is needed. In fact, those points are not really deformed. They are just being evaluated as being transformed from an axis system to another.
Rui Batista
abdelouahabb
04-04-2010, 09:06 PM
hmmmm! interresting information!
now, as am a beginner for those things, i just say thanks, then, i'll understand them slowly :D
CGTalk Moderation
04-04-2010, 09:06 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.