Stephen Sorenson Posted November 15, 2018 Share Posted November 15, 2018 So I have a custom script that I've created that works in concert with the Vectorworks Title Block object. I import info from a csv file exported from our database and it loads in fields like sales person, venue, event name, etc into the title block (via Title Block Project Data.[record field]). It also creates/updates version numbering (outside of VW revision data which is difficult to work with via script for what we're trying to do) and puts the initials of the person who most recent revised it into a drafted by field. I had to make some edits for it to work with 2018 last year, but got suitable workarounds for the issues I was having, but they've gotten worse in 2019 as I'm working on our transition. It seems that when I update the Record field it updates the title block visually, but the old information is retained "somewhere". Previously it was only an issue if I replaced the title block (it would load default data into the fields unless I had subsequently edited the title block via the project settings - but I would only have to edit one field and it would flag all of the fields as changed. Now if I edit only one field via the built in settings it will only update that one field, but all others will revert to the previous state. I was wondering if there is some way within the script to flag those fields as changed/edited so that they don't revert if I (or any of our other draftspeople) change anything via the built in editor. Quote Link to comment
Vectorworks, Inc Employee Nikolay Zhelyazkov Posted November 19, 2018 Vectorworks, Inc Employee Share Posted November 19, 2018 Hello @Stephen Sorenson, I suppose you are having issues only with the Project Data fields? The Project Data in the Title Block Border is document wide. This means that it should be the same for all TBBs in the document. That is why, we have additional logic that keeps this data consistent. When you change the data for just one Title Block, it is becoming inconsistent with the document data and that is why it is getting overwritten. If you do not want your changes to be overwritten, you will have to make them for the document too. This means that you will have to use SetRField and pass the handle of the Project Data format as first argument (you could take it with GetObject('Title Block Project Data') ). However, keep in mind that this will not update the rest of the TBBs in the document to have consistent data, unless they get reset. You could run a foreach in the end of your changes in order to reset all TBBs in the document and make their Project Data consistent with the document project data. Let me know if you have any other questions. Best Regards, Nikolay Zhelyazkov 1 Quote Link to comment
Stephen Sorenson Posted November 19, 2018 Author Share Posted November 19, 2018 @Nikolay Zhelyazkov Thank you, that's exactly what I was looking for. I still had to keep my for loop to put the project data in each individual title block's project data record in addition to the Project Data format. I already had a ResetObject (and an HMove(h, 0, 0) for good measure). Quote Link to comment
DomC Posted February 27, 2020 Share Posted February 27, 2020 On 11/19/2018 at 9:23 AM, Nikolay Zhelyazkov said: If you do not want your changes to be overwritten, you will have to make them for the document too. This means that you will have to use SetRField and pass the handle of the Project Data format as first argument (you could take it with GetObject('Title Block Project Data') ). Fantastic @Nikolay Zhelyazkov You saved my day! Quote Link to comment
twk Posted March 5, 2020 Share Posted March 5, 2020 (edited) We too have setup automatic revision control internally and externally of vectorworks. However with the new 2019 Titleblock, I can't seem to set Revision Increment value to Manual or Auto through script (vs.SetRField). Tried: - Set Plugin Default field value - Setting value/default value throughout all Titleblocks in document - Setting value/default value throughout all Plugin Style Titleblocks in document What is the logic here? @Nikolay Zhelyazkov Edited March 5, 2020 by twk Quote Link to comment
Vectorworks, Inc Employee Nikolay Zhelyazkov Posted March 5, 2020 Vectorworks, Inc Employee Share Posted March 5, 2020 Hello @twk, What are the results you are getting? Can you send me the script so that I can test it? Thanks, Nikolay Zhelyazkov Quote Link to comment
twk Posted March 9, 2020 Share Posted March 9, 2020 Apologies, my record handle for setting default values was wrong. vs.SetRField(self.plugin_object.record_def_handle, self.plugin_object.plugin_name, self.parameter_name, value) self.plugin_object.record_def_handle should be calling vs.GetObject(vs.GetName(vs.GetParametricRecord(self.handle))), not vs.GetParametricRecord(self.handle). Full script below: import vs alert_dialog = lambda x:vs.AlrtDialog(str(x)) class PluginObject(): class PluginParameter(): def __init__(self, plugin_object, parameter_name:str): self.plugin_object = plugin_object #type: PluginObject self.parameter_name = parameter_name def __str__(self): return "{}".format(self.parameter_name) @property def value(self): return vs.GetRField(self.plugin_object.handle, self.plugin_object.plugin_name, self.parameter_name) @value.setter def value(self, value): vs.SetRField(self.plugin_object.handle, self.plugin_object.plugin_name, self.parameter_name, value) vs.ResetObject(self.plugin_object.handle) @property def value_default(self): return vs.GetRField(self.plugin_object.record_def_handle, self.plugin_object.plugin_name, self.parameter_name) @value_default.setter def value_default(self, value): vs.SetRField(self.plugin_object.record_def_handle, self.plugin_object.plugin_name, self.parameter_name, value) vs.ResetObject(self.plugin_object.handle) def __init__(self, handle): self.handle = handle self.record_handle = vs.GetParametricRecord(self.handle) self.record_def_handle = vs.GetObject(vs.GetName(self.record_handle)) self.plugin_name = vs.GetName(self.record_handle) @property def list_parameters(self): data = [] for x in range(vs.NumFields(self.record_handle)): fldname = vs.GetFldName(self.record_handle, x+1) data.append(PluginObject.PluginParameter(self,fldname)) return data def get_parameter_by_name(self, parameter_name:str): for x in self.list_parameters: if x.parameter_name == parameter_name: return x tb = PluginObject(vs.FSActLayer()) revision_mark = tb.get_parameter_by_name('Revision Mark') revision_mark.value_default = 'Numbers' alert_dialog(revision_mark.value_default) Quote Link to comment
Vectorworks, Inc Employee Nikolay Zhelyazkov Posted March 9, 2020 Vectorworks, Inc Employee Share Posted March 9, 2020 Hello @twk, Your script seems to be setting the Revision Data numbering correctly. You can see that when you try to add new Revision and see that it is using the correct numbering. However, in order to change the numbering for existing revisions, you will have to do this from the Settings/Manager dialog, as from there we renumber the existing data. Other way to do this from script is to update the revision numbers from the code, but this will make the script more complicated. Best Regards, Nikolay Zhelyazkov Quote Link to comment
twk Posted March 9, 2020 Share Posted March 9, 2020 (edited) Yes, above script is a snippet of the working script, all is working well now. My problem was incorrectly setting default values. I have now managed to complete our revision cloud tool to pull and push data to the new titleblocks. Cheers Edited March 9, 2020 by twk 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.