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

SurfaceC.BooleanUnion(SurfaceA);//eGeneralModelingFailure

9 REPLIES 9
Reply
Message 1 of 10
wokeyiyognshenme
581 Views, 9 Replies

SurfaceC.BooleanUnion(SurfaceA);//eGeneralModelingFailure

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)

 

9 REPLIES 9
Message 2 of 10
_gile
in reply to: wokeyiyognshenme


@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?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 10
wokeyiyognshenme
in reply to: _gile

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

 

Message 4 of 10
_gile
in reply to: wokeyiyognshenme

Surface SurfaceA = Surface.CreateFrom(regionA);

Surface SurfaceB = Surface.CreateFrom(regionB);

 

Surface SurfaceC = Surface.CreateFrom(regionA);

SurfaceC.BooleanUnion(SurfaceB);



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 10

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();
}

Message 6 of 10
_gile
in reply to: shubhamraut221195


@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.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 7 of 10

@_gile , Then he can create SurfaceC and assign SurfaceA to SurfaceC as shows below:

Surface SurfaceC = SurfaceA;

SurfaceC.BooleanUnion(SurfaceB);

 

Without assigning SurfaceC, it is not possible to make union.

Message 8 of 10
_gile
in reply to: shubhamraut221195


@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);.


 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 9 of 10
shubhamraut221195
in reply to: _gile

Ohh right. Then how about this>  Surface SurfaceC = SurfaceA.Clone() as Surface;

Message 10 of 10
_gile
in reply to: shubhamraut221195


@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);



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report