.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Solid3d.GetSlice problem with negativeHalfToo error when set to false

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
316 Views, 2 Replies

Solid3d.GetSlice problem with negativeHalfToo error when set to false

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
2 REPLIES 2
Message 2 of 3
ChrisArps
in reply to: Anonymous

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
Message 3 of 3
Anonymous
in reply to: Anonymous

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

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost