TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
Interested in some really terrific mobile apps? Visit www.turboapps.com for details.

How to perform 3D boolean solid operations programmatically?
Read 4414 times
* June 18, 2010, 07:43:06 AM

How to perform 3D boolean solid operations programmatically?

How to programatically create a 3D solid:
1) Addition
2) Subtraction
3) Intersection
4) Slice
… using the managed TurboCAD 17 SDK?
How to trigger the creation of a solid subtraction, intersection, slicing?

What was found is that “TCW80PARTREE” is the name of the regen method that is used to create a node that is the result of a solid operation. The type of graphic object is polyline.

If the 3D objects are just added to the node created above without making any other modifications to the “TCW80PARTREE” graphic object the resulting geometry is a solid addition.

The SDK lacks of explicit interface for performing 3D solid operations.

Here is a sample code for 3D solid addition:

Code: [Select]
public enum EBooleanSolidOperation : int
{ Add
, Subtract
, Intersect
, Slice
}

public static IMSIGX.IGraphic BooleanSolidOperation
( IMSIGX.Graphics arrGraphics
, IMSIGX.IGraphic graphicExtrude1
, IMSIGX.IGraphic graphicExtrude2
, bool bRemoveBaseGeometry
, EBooleanSolidOperation operation
)
{
IMSIGX.IGraphic graphicSolidObject = null;
if (arrGraphics == null || graphicExtrude1 == null || graphicExtrude2 == null)
{
throw new System.ArgumentNullException();
}
else
{
object objMissing = System.Reflection.Missing.Value;
object objRegenType = "TCW80PARTREE";
object objGraphType = IMSIGX.ImsiGraphicType.imsiPolyline;

IMSIGX.IGraphic graphicBoolOpArg1 = bRemoveBaseGeometry ? graphicExtrude1 : graphicExtrude1.Duplicate();
IMSIGX.IGraphic graphicBoolOpArg2 = bRemoveBaseGeometry ? graphicExtrude2 : graphicExtrude2.Duplicate();

graphicSolidObject = arrGraphics.Add
( ref objGraphType
, ref objRegenType
, ref objMissing
, ref objMissing
, ref objMissing
, ref objMissing
);

IMSIGX.Graphics arrChildGraphicsParent1 = graphicBoolOpArg1.Parent as IMSIGX.Graphics;
object objObjToRemoveIndex1 = graphicBoolOpArg1.Index;
IMSIGX.IGraphic graphicBoolOpArg1Detached = arrChildGraphicsParent1.Remove(ref objObjToRemoveIndex1);
graphicSolidObject.Graphics.AddGraphic(graphicBoolOpArg1, ref objMissing, ref objMissing);


IMSIGX.Graphics arrChildGraphicsParent2 = graphicBoolOpArg2.Parent as IMSIGX.Graphics;
object objObjToRemoveIndex2 = graphicBoolOpArg2.Index;
IMSIGX.IGraphic graphicBoolOpArg2Detached = arrChildGraphicsParent2.Remove(ref objObjToRemoveIndex2);
graphicSolidObject.Graphics.AddGraphic(graphicBoolOpArg2, ref objMissing, ref objMissing);

object objCurrentView = arrChildGraphicsParent1.Application.ActiveDrawing.ActiveView;
graphicSolidObject.Draw(ref objCurrentView);
}

return graphicSolidObject;
}

How to create a Subtraction, Intersection, Slice?

The enum parameter is currently unused since no way was found to set which solid 3D operation should be performed.

Logged


* June 18, 2010, 09:20:28 AM
#1
Have a look at the Flange sample project here on the forum:
http://forums.turbocad.com/index.php/topic,320.0.html

This project demonstrates how to do Solid Adds and Subtracts with VB2008. Note the additional reference to GXEXTLIB. Although Intersection is not demonstrated, it is a third method of the GXEXT.Boolean3D object and works much like Add and Subtract.

Slice is a member of the G3Operations object in GXEXT. I don't have an example handy, but Slice also takes two objects as arguments to the function, so I would expect it to work much like Add and Subtract as well.

I'm sorry, but I can't directly speak to the use of the PartTree yet; I haven't had a chance to explore that aspect of the SDK so far.

Logged


* June 20, 2010, 02:04:42 AM
#2
Thanks a lot!

The library Interop.GXEXTLib.dll includes the following functionality:

namespace GXEXTLib
{
   public interface IGraphicG3Op
   {
      object Chamfer(object pGr1, ref object pvVertexArray, ref object pvRadiusArray);
      object Fillet(object pGr1, ref object pvVertexArray, ref object pvRadiusArray);
      object Offset(object pGr1, ref object pvVertexArray, double dShellValue);
      object Shell(object pGr1, ref object pvVertexArray, double dShellValue);
      object Slice(object pGr1, object pGr2);
   }
}

The only thing that is not clear is what kind of object is passed as a second argument to the Slice operation. It should probably be a line or a planar object - rectangle, I presume.

Thanks for providing us with the library!
Here is a list of all TurboCAD managed libraries:

Interop.GXEXTLib.dll
Interop.GXMPSLib.dll
Interop.GXRendersLib.dll
Interop.IMSIGX.dll
Interop.TCIMAGELib.dll

Are there any other available libraries? Is there any documentation about some of the listed here - what arguments should be passed to the class member functions and etc.?


Thanks a lot, again!

Logged


* September 14, 2016, 06:05:31 AM
#3
Have a look at the Flange sample project here on the forum:
http://forums.turbocad.com/index.php/topic,320.0.html

This project demonstrates how to do Solid Adds and Subtracts with VB2008. Note the additional reference to GXEXTLIB. Although Intersection is not demonstrated, it is a third method of the GXEXT.Boolean3D object and works much like Add and Subtract.

Slice is a member of the G3Operations object in GXEXT. I don't have an example handy, but Slice also takes two objects as arguments to the function, so I would expect it to work much like Add and Subtract as well.

I'm sorry, but I can't directly speak to the use of the PartTree yet; I haven't had a chance to explore that aspect of the SDK so far.
The sample at the http://forums.turbocad.com/index.php/topic,320.0.html has been removed. Does anyone know how to do a 3d boolean operation on two graphic objects or have a sample project?

Logged