.NET

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

Solid3d.GetSlice problem with negativeHalfToo error when set to false

89 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 (89 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 (89 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!