SamIWas Posted September 25, 2023 Share Posted September 25, 2023 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? Quote Link to comment
Pat Stanford Posted September 25, 2023 Share Posted September 25, 2023 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 Quote Link to comment
JBenghiat Posted September 25, 2023 Share Posted September 25, 2023 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. 1 Quote Link to comment
SamIWas Posted September 26, 2023 Author Share Posted September 26, 2023 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! Quote Link to comment
Pat Stanford Posted September 26, 2023 Share Posted September 26, 2023 GetObjectUUID was only added in 2018. CreateUUID was available since 2014. You probably started using UUIDs between those years. 😉 1 Quote Link to comment
Sam Jones Posted September 26, 2023 Share Posted September 26, 2023 17 hours ago, JBenghiat said: You can use object state events to catch new and duplicated objects. How? Quote Link to comment
JBenghiat Posted September 27, 2023 Share Posted September 27, 2023 https://developer.vectorworks.net/index.php/VS:Parametric_State_Notifications#kCreatedReset Quote Link to comment
SamIWas Posted September 27, 2023 Author Share Posted September 27, 2023 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. Quote Link to comment
JBenghiat Posted September 27, 2023 Share Posted September 27, 2023 (edited) 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 September 27, 2023 by JBenghiat 1 Quote Link to comment
Recommended Posts
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.