VCOM:VectorWorks:ISDK::BuildConstraintModelForObject

From Vectorworks Developer
Jump to navigation Jump to search

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

Description

namespace VectorWorks

Member of VCOM:VectorWorks:ISDK

Create a constraint model for the specified object in the constraint manager. If 'traverseContainers' is true and the specified object is a symbol definition, a group or another container-like objects, it will go deep inside that container.

This function should typically be called for constrained objects that have been duplicated and newly inserted into the drawing.

virtual void VCOM_CALLTYPE BuildConstraintModelForObject(
MCObjectHandle objectHandle,
bool traverseContainers) = 0;

Parameters

objectHandle MCObjectHandle Handle to object.
traverseContainers bool Whether to traverse containers-like objects.

Example


void DuplicateObjectsAndPreserveConstraints()
{
	
	// All objects duplicated within the scope of the Begin/EndMultipleDuplicate() should have their
	// constraints references properly reassigned.
	// mark the start of a multiple objects duplicate that preserves constraints
	gSDK->BeginMultipleDuplicate();

	for(...) // for each object to be duplicated
	{ 
		// Duplicate objects
		MCObjectHandle	hCopy = gSDK->DuplicateObject(h);
		// Insert them into the document, 
		// but do not perform any operation that expects the references/constraints to be valid.
		gSDK->AddObjectToContainer(hCopy, layer);
	}
	// end the multiple objects duplicate process.
	gSDK->EndMultipleDuplicate();

	// Now that the duplicate process was ended, the duplicate objects have valid references.

	// Now register the new objects into the Constraint Manager and build a model.
	// This sequence may require you to make a list of the duplicated objects so you can loop through at your convenience.
	// You can also choose to use a ForEachObject call if you can set it to only hit the new duplicated objects
	
	for (...) // for each duplicated object
	{ 
		//
		gSDK->BuildConstraintModelForObject(hCopy, true);
		
		// You should call BuildConstraintModelForObject() it with 'traverseContainers' set to FALSE if your are calling it from within a
		// ForEachObject() call that is already set to traverse deep inside containers.  
		// This is to avoid double traversals of the containers that could impact the performance or cause any other problem.
	}

	// At this point, constraints on your duplicated objects are operational
	// Now you can do everything else.
	.
	.
	.

}

Version

Availability: from Vectorworks 2010