.NET

Reply
Distinguished Contributor
116 Posts
1 Kudo
Registered: ‎02-26-2009
Post 1 of 8
Accepted Solution

Reversing a Boolean operation.

301 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
388 Posts
30 Kudos
Registered: ‎03-31-2005
Post 2 of 8

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*
2,142 Posts
255 Kudos
Registered: ‎04-29-2006
Post 3 of 8

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
116 Posts
1 Kudo
Registered: ‎02-26-2009
Post 4 of 8

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
116 Posts
1 Kudo
Registered: ‎02-26-2009
Post 5 of 8

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
116 Posts
1 Kudo
Registered: ‎02-26-2009
Post 6 of 8

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*
1,569 Posts
171 Kudos
Registered: ‎10-08-2008
Post 7 of 8

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
116 Posts
1 Kudo
Registered: ‎02-26-2009
Post 8 of 8

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 interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!