.NET

Reply
Distinguished Contributor
junoj
Posts: 116
Registered: ‎02-26-2009
Message 1 of 8 (279 Views)
Accepted Solution

Reversing a Boolean operation.

279 Views, 7 Replies
09-25-2013 01:13 PM

I would like to reversing a Boolean operation if an error happens.

 

I have two solids that when I try to perform a Subtract Boolean Operation gives me an error. When the error happens I lose both solids. I would like to be able to reverse the subtraction in an event of an error so that I still have both solids.

 

Thank you in advance.

 

Dim Solid_1 as Solid3d = CreateSoldFromPl(plinePoints1)
Dim Solid_2 as Solid3d = CreateSoldFromPl(plinePoints1)

Try
    Solid_1.BooleanOperation(BooleanOperationType.BoolSubtract, Solid_2)
End Try

 

Citation

You should delete a smaller solid right after this line of code,
otherwise you leave a solid with degenerate geometry
(i.e. zero geometry) in the database and that could cause issues:
           
solid1.BooleanOperation(BooleanOperationType.BoolSubtract, solid2)

 

Add this line:

 

solid2.Erase()

 

tr.Commit() etc

 

Found this explanation in my code collection

Valued Mentor
fieldguy
Posts: 376
Registered: ‎03-31-2005
Message 2 of 8 (273 Views)

Re: Reversing a Boolean operation.

09-25-2013 01:39 PM in reply to: junoj

Have you tried "Catch"?  It looks as if you are not using a catch statement which is what it was designed for.

*Expert Elite*
_gile
Posts: 2,103
Registered: ‎04-29-2006
Message 3 of 8 (266 Views)

Re : Reversing a Boolean operation.

09-25-2013 01:52 PM in reply to: junoj

I do not konw anything about the 'CreateSoldFromPl' method, but it looks like you're substracting a solid to an indentical one (the same 'plinePoints1' argument for both 'Solid_1' and 'Solid_2').

Gilles Chanteau
Distinguished Contributor
junoj
Posts: 116
Registered: ‎02-26-2009
Message 4 of 8 (252 Views)

Re: Reversing a Boolean operation.

09-25-2013 02:35 PM in reply to: fieldguy

Hi Fieldguy,

 

Yes I have tried the Try Catch , but it just catches the error. The solids are consumed after the unsuccessful subtraction.

Distinguished Contributor
junoj
Posts: 116
Registered: ‎02-26-2009
Message 5 of 8 (251 Views)

Re : Reversing a Boolean operation.

09-25-2013 02:38 PM in reply to: _gile

Gilles,

 

Sorry, i just had a typo. The CreateSoldFromPL is just a function that creates a solid from polyline.

 

Updated Code

Dim Solid_1 as Solid3d = CreateSoldFromPl(plinePoints1)
Dim Solid_2 as Solid3d = CreateSoldFromPl(plinePoints2)

Try
    Solid_1.BooleanOperation(BooleanOperationType.BoolSubtract, Solid_2)
End Try

 

Distinguished Contributor
junoj
Posts: 116
Registered: ‎02-26-2009
Message 6 of 8 (245 Views)

Re : Reversing a Boolean operation.

09-25-2013 02:44 PM in reply to: junoj

Sorry, I should have posted the error that i get:

 

The Boolean operation on solids failed.

Modeling Operation Error:

System inconsistency processing edge coincidence.

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 7 of 8 (203 Views)

Re : Reversing a Boolean operation.

09-26-2013 06:29 AM in reply to: junoj

Citation

You should delete a smaller solid right after this line of code,
otherwise you leave a solid with degenerate geometry
(i.e. zero geometry) in the database and that could cause issues:
           
solid1.BooleanOperation(BooleanOperationType.BoolSubtract, solid2)

 

Add this line:

 

solid2.Erase()

 

tr.Commit() etc

 

Found this explanation in my code collection

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Distinguished Contributor
junoj
Posts: 116
Registered: ‎02-26-2009
Message 8 of 8 (189 Views)

Re : Reversing a Boolean operation.

09-26-2013 08:51 AM in reply to: Hallex

Thank you Fieldguy, Gilles and Hallex.

 

I must have had a brain freeze. I was able to reverse it by using a nested transaction. This was my first time using a nested transaction . . .

 

Thank you again.

 

-J

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.