Jump to content
Developer Wiki and Function Reference Links ×

Entering a unique field value for new/duplicated objects


SamIWas

Recommended Posts

For most of my PIOs, I have a unique ID field used for importing and exporting to FileMaker Pro.  I have always done this by having an ID field, entering the same value into the Object Name, then changing the ID field if the two don't match (since VW will change the name of any conflicting object names automatically).  But, now that I've learned about 3.7% of how to use Event-Enabled objects, I'd like to make this work in a more standard way.

 

I tried doing this in the kObjOnInitXProperties section, which I think runs when the object is new or duplicated (?), but I couldn't seem to pull object field data in there.  I also couldn't pass a variable from that section into the rest of the code.  Where in the event code can I assign a variable with a UUID, which changes only if the object is new or duplicated, and pass that into the main code to change the ID field if it's different?

Link to comment

kObjOnInitXProperties runs once per session (Vectorworks open until quit), unless you are running scripts in developer mode, in which case objects are forced to re-initialize on every run. 
You can use object state events to catch new and duplicated objects. 
Alternatively, have your export script pull directly from the objects’ Uuid (see Pat’s post above), rather than depending on a record field. 

  • Like 1
Link to comment
11 hours ago, Pat Stanford said:

Short version:

 

Record with field for Stored_UUID and Unique_ID.

When object refreshes vs.GetObjectUUID.

Compare retrieved UUID with stored UUID.

If they match then continue with redraw.

If they do not match, clear Unique_ID and put new value. Replace Stored_UUID with retrieved UUID.

Continue with rest of redraw.

 

HTH

 

 

 

5 hours ago, JBenghiat said:

kObjOnInitXProperties runs once per session (Vectorworks open until quit), unless you are running scripts in developer mode, in which case objects are forced to re-initialize on every run. 
You can use object state events to catch new and duplicated objects. 
Alternatively, have your export script pull directly from the objects’ Uuid (see Pat’s post above), rather than depending on a record field. 

 

Holy moly.  How did I never see the getUUID command???  I've been creating them using CreateUUID and applying them to text fields for years using all these tricks to create new ones....and, of course, VW just does it.  Guess I need to do another round of updates!

Link to comment
12 hours ago, Pat Stanford said:

GetObjectUUID was only added in 2018. CreateUUID was available since 2014.  You probably started using UUIDs between those years. 😉

 

 

You are correct.  I'm pretty sure I built those plugins before 2018.  Now...another question...is there a way to write TO Vectorworks UUID?  As in, overwrite the value VW gives it?   Because with my VW/Filemaker data transfers, I sometimes have object created in Filemaker first which then get imported back into VW.  The objects in Filemaker are given a UUID which would need to track to VW.  So as part of the import process, I would want to tell VW what the object's UUID is.  

Link to comment
11 hours ago, SamIWas said:

is there a way to write TO Vectorworks UUID?

No, the UUID is core to project sharing, so Vectorworks is dependent on the objects maintaining the UUID generated at creation. 
You probably need to keep two sets of IDs: The database ID and the VW ID. I believe you can set the VW ID field to be unique but not required, so that new rows won’t duplicate the UUID. FileMaker should allow you to specify a unique index field. 
Alternatively, you can have a related table that just maps FileMaker record IDs to VW IDs

Edited by JBenghiat
  • Like 1
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...