Relocate Object From One Page Layout To Another

Average rating
(0 votes)

// Relocates a page layout object from one layout to another.
// If destObjectName is different from sourceObjectName, renames the object during the relocation.
// In this case, it is up to you to make sure that destObjectName is valid and not in conflict.
Function RelocateLayoutObject(sourceLayoutName, sourceObjectName, destLayoutName, destObjectName)
	String sourceLayoutName, sourceObjectName
	String destLayoutName, destObjectName
 
	String sourceInfo = LayoutInfo(sourceLayoutName, sourceObjectName)
 
	RemoveLayoutObjects /W=$sourceLayoutName $sourceObjectName
 
	if (CmpStr(sourceObjectName,destObjectName) != 0)
		DoWindow /C /W=$sourceObjectName $destObjectName
	endif
 
	Variable fidelity = NumberByKey("FIDELITY", sourceInfo)
	Variable frame = NumberByKey("FRAME", sourceInfo)
	Variable trans = NumberByKey("TRANS", sourceInfo)
	Variable left = NumberByKey("LEFT", sourceInfo)
	Variable top = NumberByKey("TOP", sourceInfo)
	Variable width = NumberByKey("WIDTH", sourceInfo)
	Variable height = NumberByKey("HEIGHT", sourceInfo)
	Variable right = left + width
	Variable bottom = top + height
	String objectType = StringByKey("TYPE", sourceInfo)
 
	AppendLayoutObject /W=$destLayoutName /D=(fidelity) /F=(frame) /R=(left,top,right,bottom) /T=(trans) $objectType $destObjectName
End

Back to top