Difference between revisions of "SDK:Intersecting Surfaces"

From Vectorworks Developer
Jump to: navigation, search
(Created page with "{{LocationMain|category=LocationSDKSpecial|specific=}} <div class="rightmenu"> __TOC__ </div> == What's that == This article will explain how to create the surface objects t...")
 
(Added another way, info provided by Abdel.)
 
Line 9: Line 9:
  
 
== Creating ==
 
== Creating ==
To create a surface intersection between two surface objects, use :
+
There are different ways to accomplish this. Here are two ways of doing this:
 +
 
 +
=== IPoly2DOperations ===
 +
See example below.
 +
 
 +
=== Kludge ===
 
<code lang="cpp">
 
<code lang="cpp">
 
gSDK->Kludge( kIntersectSurfaceKludge, &surfaceInformation, nil );
 
gSDK->Kludge( kIntersectSurfaceKludge, &surfaceInformation, nil );
Line 15: Line 20:
 
* ''kIntersectSurfaceKludge'' is a const CBSignedShort with 5571 as value.
 
* ''kIntersectSurfaceKludge'' is a const CBSignedShort with 5571 as value.
 
* ''doubleParams'' is a struct with 3 MCObjectHandles parameters (object1, object2 and the result of the intersection between the two objects).
 
* ''doubleParams'' is a struct with 3 MCObjectHandles parameters (object1, object2 and the result of the intersection between the two objects).
 +
 +
''BE AWARE, this will give an undo warning!''
  
 
== Example ==
 
== Example ==
 +
=== IPoly2DOperations ===
 +
<code lang="cpp">
 +
void DEExtWD::Helpers::IntersectTwoObjects(Handle& h1, Handle h2, TVWArray_MCObjectHandle & hResultArray)
 +
{
 +
if(VERIFYN(kAbdel, h1 != nil && h2 != nil)) {
  
 +
VWFC::IPoly2DMathPtr intersectionOp( VWFC::IID_Poly2DMath );
 +
VWFC::IPoly2DOperationsPtr boolPtr( VWFC::IID_Poly2DOperations );
 +
 +
VWFC::IPolyDefPtr h1DefPoly;
 +
VWFC::IPolyDefPtr h2DefPoly;
 +
VWFC::IPolyDefArrayPtr intersectionH;
 +
Uint32 len;
 +
 +
intersectionOp->CreatePoly(h1, &h1DefPoly);
 +
intersectionOp->CreatePoly(h2, &h2DefPoly);
 +
 +
if(h1DefPoly != nil && h2DefPoly != nil) {
 +
 +
boolPtr->IntersectSurface(h1DefPoly, h2DefPoly, &intersectionH);
 +
 +
if(intersectionH != nil)
 +
{
 +
intersectionH->Size(len);
 +
VWFC::IPolyDefPtr poly;
 +
for(Uint32 i=0; i<len; i++) {
 +
intersectionH->Get(i, &poly);
 +
Handle h = nil;
 +
intersectionOp->CreateHandle(poly, h);
 +
if (h != nil)
 +
hResultArray.Append(h);
 +
}
 +
}
 +
}
 +
}
 +
}
 +
</code>
  
 +
=== Kludge ===
 
<code lang="cpp">
 
<code lang="cpp">
 
MCObjectHandle IntersectSurface(MCObjectHandle obj1, MCObjectHandle obj2)
 
MCObjectHandle IntersectSurface(MCObjectHandle obj1, MCObjectHandle obj2)

Latest revision as of 02:51, 16 September 2014

.SDK|SDK ..SDK:Types|SDK Types ..SDK:Using the SDK|Using the SDK ..VCOM:VCOM (Vectorworks Component Object Model)|VCOM Basics ..VCOM:Class Reference|VCOM Class Reference

What's that

This article will explain how to create the surface objects that are the intersection of the two referenced surface objects.

Creating

There are different ways to accomplish this. Here are two ways of doing this:

IPoly2DOperations

See example below.

Kludge

	gSDK->Kludge( kIntersectSurfaceKludge, &surfaceInformation, nil );
  • kIntersectSurfaceKludge is a const CBSignedShort with 5571 as value.
  • doubleParams is a struct with 3 MCObjectHandles parameters (object1, object2 and the result of the intersection between the two objects).

BE AWARE, this will give an undo warning!

Example

IPoly2DOperations

void DEExtWD::Helpers::IntersectTwoObjects(Handle& h1, Handle h2, TVWArray_MCObjectHandle & hResultArray)
{
	if(VERIFYN(kAbdel, h1 != nil && h2 != nil)) {

		VWFC::IPoly2DMathPtr intersectionOp( VWFC::IID_Poly2DMath );
		VWFC::IPoly2DOperationsPtr boolPtr( VWFC::IID_Poly2DOperations );

		VWFC::IPolyDefPtr h1DefPoly;
		VWFC::IPolyDefPtr h2DefPoly;
		VWFC::IPolyDefArrayPtr intersectionH;
		Uint32 len;

		intersectionOp->CreatePoly(h1, &h1DefPoly);
		intersectionOp->CreatePoly(h2, &h2DefPoly);

		if(h1DefPoly != nil && h2DefPoly != nil) {

			boolPtr->IntersectSurface(h1DefPoly, h2DefPoly, &intersectionH);

			if(intersectionH != nil) 
			{
				intersectionH->Size(len);
				VWFC::IPolyDefPtr poly;
				for(Uint32 i=0; i<len; i++) {
					intersectionH->Get(i, &poly);
					Handle h = nil;
					intersectionOp->CreateHandle(poly, h);
					if (h != nil)
						hResultArray.Append(h);
				}
			}
		}
	}
}

Kludge

MCObjectHandle IntersectSurface(MCObjectHandle obj1, MCObjectHandle obj2)
{
	const CBSignedShort kIntersectSurfaceKludge = 5571;
	struct IntersectSurfaceInformation
	{
		MCObjectHandle h1;
		MCObjectHandle h2;
		MCObjectHandle result;
	};

	IntersectSurfaceInformation surfaceInformation;
	surfaceInformation.h1 = listObj1[i];
	surfaceInformation.h2 = listObj2[j];
	gSDK->Kludge(kIntersectSurfaceKludge, &surfaceInformation, nil);
	
	return surfaceInformation.result;
}

See also

VCOM:VectorWorks:ISDK::Kludge

Personal tools
NamespacesFFFF

Variants
Actions
Advanced Search
See Also
Navigation
Toolbox