.NET

Reply
*Laurence Skoropinski
Message 1 of 3 (81 Views)

Solid3d.GetSlice problem with negativeHalfToo error when set to false

81 Views, 2 Replies
12-12-2005 02:08 AM
When using the GetSlice method of the Solid3d class and setting the
negativeHalfToo to false I get the following exception, "Operation is not
valid due to the current state of the object.", but if I set it to true It
works as expected. What am I doing wrong?


[CommandMethod("GetMySlice")]

static public void GetMySlice()

{

Database db = HostApplicationServices.WorkingDatabase;

Transaction myT = db.TransactionManager.StartTransaction(); //begin the
transaction

Editor ed =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;


try

{

//use sphere command and create sphere at 0,0,0 any radius manually


PromptEntityOptions prEnt = new PromptEntityOptions("\nPlease select a Solid
entity: ");

PromptEntityResult prEntRes = ed.GetEntity(prEnt);

if( prEntRes.Status == PromptStatus.OK)

{


Entity selectedEntity = (Entity)myT.GetObject(prEntRes.ObjectId,
OpenMode.ForWrite);

Solid3d MySolid = (Solid3d)selectedEntity;


Plane CutPlane = new Plane(new Point3d(0.0,0.0,0.0),new
Vector3d(0.0,1.0,0.0));

MySolid.GetSlice(CutPlane, false); //OK comment this out and use lines
below, no error checking as just testing

// Solid3d OtherHalf = MySolid.GetSlice(CutPlane, true);

// BlockTable bt = (BlockTable)myT.GetObject(db.BlockTableId,
OpenMode.ForRead, false);

// BlockTableRecord btr =
(BlockTableRecord)myT.GetObject(bt[BlockTableRecord.ModelSpace],
OpenMode.ForWrite, false);

// btr.AppendEntity(OtherHalf);

// myT.AddNewlyCreatedDBObject(OtherHalf, true);


myT.Commit();

}

}

catch ( System.Exception e )

{

ed.WriteMessage("Error: " + e.Message);

}

finally

{

myT.Dispose();

}


}



Laurence
Distinguished Contributor
ChrisArps
Posts: 311
Registered: ‎07-29-2004
Message 2 of 3 (81 Views)

Re: Solid3d.GetSlice problem with negativeHalfToo error when set to false

12-15-2005 01:15 PM in reply to: *Laurence Skoropinski
I do not see that you are doing anything wrong, especially since we are just talking about a simple boolean parameter.

You could always negate the normal vector to flip the plane and get the other half of the solid.

Chris Arps
*Laurence Skoropinski
Message 3 of 3 (81 Views)

Re: Solid3d.GetSlice problem with negativeHalfToo error when set to false

12-16-2005 12:08 AM in reply to: *Laurence Skoropinski
Thank for replying. I am thinking of getting the neg half and disposing it.

Laurence
wrote in message news:5039399@discussion.autodesk.com...
I do not see that you are doing anything wrong, especially since we are just
talking about a simple boolean parameter.

You could always negate the normal vector to flip the plane and get the
other half of the solid.

Chris Arps

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community