Surface SurfaceA=Surface.CreateFrom(regionA); //ok
Surface SurfaceB =Surface.CreateFrom(regionB);//ok
Surface SurfaceC = new Surface();
SurfaceC.BooleanUnion(SurfaceA);//failure
SurfaceC.BooleanUnion(SurfaceB);//failure
Autodesk.AutoCAD.Runtime.Exception: eGeneralModelingFailure
在 Autodesk.AutoCAD.DatabaseServices.Surface.BooleanUnion(Surface surface2)
@wokeyiyognshenme a écrit :
Surface SurfaceA=Surface.CreateFrom(regionA); //ok
Surface SurfaceB =Surface.CreateFrom(regionB);//ok
Surface SurfaceC = new Surface();
SurfaceC.BooleanUnion(SurfaceA);//failure
SurfaceC.BooleanUnion(SurfaceB);//failure
What did you expected with unioning a new (uncreated) Surface with a regular one?
YOU mean
Surface SurfaceC = new Surface(); after this, the surfaceC does not create.
Surface SurfaceA=Surface.CreateFrom(regionA); //ok
Surface SurfaceB =Surface.CreateFrom(regionB);//ok
A and B are not on the save plane. (are not Coplanar).
but they have a save edge
how to union A and B ? C=A+B
There is no need to create 3rd surface. Just do Union operation of surfaceB to SurfaceA. What you are actually doing is creating null surface 'SurfaceC' and adding SurfaceA to SurfaceC. But here SurfaceC is null so cannot do union operation. Use following block of code instead.
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
BlockTable bt = tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
PromptEntityResult result1 = doc.Editor.GetEntity("Select region1");
Region regionA = tr.GetObject(result1.ObjectId, OpenMode.ForWrite) as Region;
result1 = doc.Editor.GetEntity("Select region2");
Region regionB = tr.GetObject(result1.ObjectId, OpenMode.ForWrite) as Region;
Surface SurfaceA = Surface.CreateFrom(regionA); //ok
Surface SurfaceB = Surface.CreateFrom(regionB);//ok
SurfaceA.BooleanUnion(SurfaceB);
btr.AppendEntity(SurfaceA);
tr.AddNewlyCreatedDBObject(SurfaceA, true);
tr.Commit();
}
@shubhamraut221195 a écrit :
There is no need to create 3rd surface. Just do Union operation of surfaceB to SurfaceA. What you are actually doing is creating null surface 'SurfaceC' and adding SurfaceA to SurfaceC. But here SurfaceC is null so cannot do union operation. Use following block of code instead.
It depends on what you want to achieve. It seems that the OP wants to keep SurfaceA and SurfaceB as they are and create a third SurfaceC, which would be the union of the first two.
@shubhamraut221195 a écrit :
@_gile , Then he can create SurfaceC and assign SurfaceA to SurfaceC as shows below:
Surface SurfaceC = SurfaceA;
SurfaceC.BooleanUnion(SurfaceB);
Nope, doing this does not create a new Surface named 'SurfaceC'. It just creates a variable named 'SurfaceC' which points to the same Surface instance as SurfaceA. So, SurfaceC.BooleanUnion(SurfaceB); is exactly the same as doing SurfaceA.BooleanUnion(SurfaceB);.
Ohh right. Then how about this> Surface SurfaceC = SurfaceA.Clone() as Surface;
@shubhamraut221195 a écrit :
Ohh right. Then how about this> Surface SurfaceC = SurfaceA.Clone() as Surface;
This should work the same as: Surface SurfaceC = Surface.CreateFrom(regionA);
Can't find what you're looking for? Ask the community or share your knowledge.