Jump to content
Developer Wiki and Function Reference Links ×

Create New Layer Event


Recommended Posts

Thanks for your reply. To elaborate, I have an event enabled object on a layer (sheet or design). The object has a hidden parameter that contains a unique ID generated using CreateUUID. This name is also given to a locus within the object's profile group. When the layer is duplicated, the locus loses its name and the unique ID field is no longer unique. This can be problematic down the track.

 

If the object could detect its creation, it could rectify this and generate a new unique ID. Thanks for any ideas.

Link to comment
  • Vectorworks, Inc Employee

You can try to look for the state kObjectCreated (13), not sure if Vectorscript will get this notification or not.

It was added for 2012.

 

The problem is that you you are using the name field of the locus.

If you attach a hidden record to the loci then duplication would be less problematic.

The other issue is that the locus is a dumb object so it can't react to a change.

 

I would try changing your logic slightly.

Store the UUID in a hidden field of the PIO AND name the PIO with the UUID. With a PIO you can Hide and disable the object name so the user can't change it.

Attach a record to the the loci with the UUID as a record field. (You can also name the Loci with the UUID+"Loci" to make it easier to find but you can't keep the user form changing it.)

When you need to find the loci you can do a quick name search for the UUID+Loci, or do a more complex search for the record and filed value if it fails.

 

When the user duplicates the PIO, the object name will change but your hidden UUID will stay the same. You will know the PIO has been duplicated when the UUID does not match the name. Generate a new UUID and rename the object.

The duplicated Loci will still have the record attached with the old UUID but you can find it and update it with the new UUID.  (For VS this portion of the workflow will fail with duplicate array because could have multiple loci with the same UUID in the record field but you can check the parent to see what the new UUID should be.)

Link to comment

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.

Guest
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.

×
×
  • Create New...