.NET

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

Reversing a Boolean operation.

290 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: 379
Registered: ‎03-31-2005
Message 2 of 8 (284 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,115
Registered: ‎04-29-2006
Message 3 of 8 (277 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 (263 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 (262 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 (256 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 (214 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 (200 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
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!