Jump to content
Carles Olle

Duplicate symbols sharing internal object instance

Recommended Posts



I'm creating PIO that can be created inside a symbol. I'm using a code similar to this:

def execute():

	objDlg = createObjectDialog()
	if vs.RunLayoutDialog(objDlg, objectDialogHandler) == kOK:
		if createSymbol == "True":
		object = vs.CreateCustomObject("MyObject", 0, 0, 0)
		vs.Record(picture, "MyObject")
		vs.Field(picture, "MyObject", "objectName", objectName)
		vs.SetName(object, objectName)
		if createSymbol == "True":

The symbol is created properly.

The problem comes when, from the Resource Manager panel you right click the created symbol and select "Duplicate..."; When you duplicate the symbol, the object instance of the original symbol is used for the duplicated symbol. In this way, if you modify the object inside the duplicated symbol, the object inside the original symbol (same instance) is also affected.


Is there a way to force to create a new object instance (copy) whenever you duplicate a symbol?




Share this post

Link to post

This is how symbols are designed to work. Only the definition is unique, all placed symbols are exact copies.

The only way around, is to make your wrapper an object, or maybe your current object the parent of whatever you want to create. Then each object instance can be unique.


Also, you can still save that object as a red symbol if you want it to appear in the resource browser as well.

Share this post

Link to post

Is the snippet above part of the PIO, or a separate menu command that places the PIO inside a symbol.  If it is part of the PIO, you should only do this as part of a button press.


If I'm understanding the scenario correctly, you have a PIO inside of a symbol.  You then duplicate the symbol in the resource browser.  What you see is expected--the duplicated symbol contains an exact duplicate of the PIO.  You should be able to edit the symbol definition and change the parameters of the PIO without the original PIO changing.


If you're looking to have the duplicated PIO do something on duplication, like generate a unique ID number, you can set the PIO to event enabled and respond to the object-created event.



Share this post

Link to post

Hi Josh,


Yes, the code is part of a menu command.

Yes, your understanding is correct.


I take some actions when the PIO instance is duplicated; Change a contained Image Prop, change the ID, etc.

The PIO entry function is called when I duplicate the PIO manually (not as part of a symbol duplication) but the PIO entry function does not seem to be called when the duplication happens as part of a symbol duplication and the two PIOs end up containing the same Image Prop.


This is the snipped I use for the kObjOnInitXProperties event handling:


    if theEvent == vs.kObjOnInitXProperties:
        # Enable custom shape pane
        _ = vs.SetObjPropVS( vs.kObjXPropHasUIOverride, True )
        _ = vs.SetObjPropVS( vs.kObjXHasCustomWidgetVisibilities, True )
        vs.SetPrefInt(vs.varParametricEnableStateEventing, 1)
        _ = vs.SetObjPropVS( vs.kObjXPropAcceptStates, True )
        _ = vs.SetObjPropVS( vs.kObjXPropAcceptStatesInternal, True )





Share this post

Link to post

Your object appears to be event enabled and accepting states.  You want to check for this state:     kObjectCreated = 13.  This will be true when the object is created via any method, including inserting and duplicating.



Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114


© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

  • Create New...