VCOM:VectorWorks:ISDK::EndMultipleDuplicate

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

Use this function in conjunction with BeginMultipleDuplicate to preserve constraints when duplicating multiple objects.

virtual void VCOM_CALLTYPE EndMultipleDuplicate( ) = 0;

Parameters

Remarks

By wrapping your code that duplicates objects between a BeginMultipleDuplicate() and EndMultipleDuplicate() calls, you ensure that the duplicated objects will maintain existing constraints between them.

Note: Failure to call EndMultipleDuplicate() to close a multiple duplicate that was started with BeginMultipleDuplicate() will result in system instability and file corruption.

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

See Also

BeginMultipleDuplicate

[[VCOM:VectorWorks:ISDK::BeginMultipleDuplicate|BeginMultipleDuplicate]]