PDA

View Full Version : need help in XPresso scripts


libya82
01-22-2008, 10:13 AM
Hi there ...

when i execute :
CallCommand(5168);
to create a plane

but how i change the width & height ....

and when i make it editable how i select specific edge to extrude ?

thanks ...:)

Darter
01-22-2008, 01:14 PM
This script creates a plane and sets the parameters:
var plane = AllocObject(Oplane);
doc->InsertObject(plane, NULL, NULL);
if(!plane) return;
doc->AddUndo(UNDO_OBJECT_NEW, plane);

plane#PRIM_PLANE_WIDTH = 400; //Width
plane#PRIM_PLANE_HEIGHT = 400; //Height
plane#PRIM_PLANE_SUBW = 20; //Width Segments
plane#PRIM_PLANE_SUBH = 20; //Height Segments
plane#PRIM_AXIS = 2; //Orientation

Do you want to automatically select an edge using COFFEE? Edges aren't supported in COFFEE but you can select the edge points and convert them to an edge like this:
var bs = op->GetPointSelection();
bs->Select(377); //Point index 377
bs->Select(356); //Point index 356
op->SetPointSelection(bs);

var bc = new(BaseContainer);
bc->SetData(MDATA_CONVERTSELECTION_LEFT, 0);
bc->SetData(MDATA_CONVERTSELECTION_RIGHT, 1);
SendModelingCommand(MCOMMAND_CONVERTSELECTION, doc, op, bc, MODIFY_POINTSELECTION);
CallCommand(16351); //Edge Tool

Of course, you need to replace the indices with the ones for your edge.

To do it manually you simply click on an edge with the Edge Tool active.

libya82
01-22-2008, 01:37 PM
thank pal ...

that's what i need ... thanks :thumbsup:

libya82
01-22-2008, 02:32 PM
i try your code ... the two parts like this :

var plane = AllocObject(Oplane);
doc->InsertObject(plane, NULL, NULL);
if(!plane) return;
doc->AddUndo(UNDO_OBJECT_NEW, plane);

plane#PRIM_PLANE_WIDTH = 400; //Width
plane#PRIM_PLANE_HEIGHT = 400; //Height
plane#PRIM_PLANE_SUBW = 1; //Width Segments
plane#PRIM_PLANE_SUBH = 1; //Height Segments
plane#PRIM_AXIS = 2; //Orientation

var bs = op->GetPointSelection();
bs->Select(2); //Point index 2
bs->Select(3); //Point index 3
op->SetPointSelection(bs);

var bc = new(BaseContainer);
bc->SetData(MDATA_CONVERTSELECTION_LEFT, 0);
bc->SetData(MDATA_CONVERTSELECTION_RIGHT, 1);
SendModelingCommand(MCOMMAND_CONVERTSELECTION, doc, op, bc, MODIFY_POINTSELECTION);
CallCommand(16351); //Edge Tool


the palne created ... but not editable and the edge not selected

the create part is ok ... and the selection part is ok too .. but not together

what's wrong ??:)

i want it like this ...
http://img527.imageshack.us/img527/983/65654025jq0.jpg

Darter
01-23-2008, 01:37 AM
I didn't realize that you wanted everything combined in a single script. This seems to work okay:
var plane = AllocObject(Oplane);
doc->InsertObject(plane, NULL, NULL);
if(!plane) return;
doc->AddUndo(UNDO_OBJECT_NEW, plane);

plane#PRIM_PLANE_WIDTH = 400; //Width
plane#PRIM_PLANE_HEIGHT = 400; //Height
plane#PRIM_PLANE_SUBW = 1; //Width Segments
plane#PRIM_PLANE_SUBH = 1; //Height Segments
plane#PRIM_AXIS = 2; //Orientation

var bc = new(BaseContainer);
SendModelingCommand(MCOMMAND_MAKEEDITABLE, doc, plane, bc, MODIFY_ALL);

plane = doc->GetFirstObject();
var bs = plane->GetPointSelection();
bs->Select(0);
bs->Select(1);
plane->SetPointSelection(bs);

bc->SetData(MDATA_CONVERTSELECTION_LEFT, 0);
bc->SetData(MDATA_CONVERTSELECTION_RIGHT, 1);
SendModelingCommand(MCOMMAND_CONVERTSELECTION, doc, plane, bc, MODIFY_POINTSELECTION);
CallCommand(16351); //Edge Tool

libya82
01-23-2008, 09:26 AM
yes it is works perfectly ...

thanks Darter ... appreciated :applause:

CGTalk Moderation
01-23-2008, 09:26 AM
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.