relume Posted December 13, 2016 Share Posted December 13, 2016 Hello I would like to create a custom dialog where I can select in a pulldown-menu a list of all databases in the actual document. In a second pulldown-menu I woud like to show the corresponding database-fields. What I am missing in the vs function references are the appropriate vs functions to get/retrieve those lists. Do I have missed or overseen something? many thanks in advance. Quote Link to comment
MullinRJ Posted December 13, 2016 Share Posted December 13, 2016 I do not think there is a direct way to extract those lists. You'll have to query each row in each WS to see if it is a database row and build a list from that. Start with IsWSDatabaseRow(), and loop through your WS rows to build your list. Since Python has some phenomenal list handling capabilities, you might consider writing your script with Python. I'm sure you can do the same in Pascal, but you'll have to code many things that Python already has built In. If you need further insight, wait for Pat Stanford's reply. He speaks Worksheet fluently. :-) Raymond Quote Link to comment
relume Posted December 13, 2016 Author Share Posted December 13, 2016 Hello Raymond Thank you very much for your answer. Yes I am scripting in python, but I have to rely on vs.functions in order to access VW information/data. I do not use worksheets and in this sens I would like only to obtain a list of all databases (not the record instances) that are present in the VW document in order I can generate a generic dialog/script for which the user can select the appropriate database and database-field to operate on (in this case to label or rotate objects arrcording to an database-field value selected by the user at script runtime). best regards 1 Quote Link to comment
JBenghiat Posted December 13, 2016 Share Posted December 13, 2016 I assume by database, you mean record format. Use NumRecords() and GetRecord(): http://developer.vectorworks.net/index.php/VS:NumRecords http://developer.vectorworks.net/index.php/VS:GetRecord Passing a nil handle will give you records attached to the entire document as opposed to a specific object. When filling the dialog, you will need to check if the record is hidden and if it is a plug-in format if you want to filter those out. -Josh Quote Link to comment
relume Posted December 13, 2016 Author Share Posted December 13, 2016 Hello Josh Thank you very much - your tip did it. Although it is some bit strange that VectorWorks does not document this special case with the nil handle to access the databases/records attached to the document itself. The following python script snippet shows how it works. Maybe it helps others ... import vs vHandle = "" vRecordsNum = vs.NumRecords(vHandle) vs.AlrtDialog("Databases : " + str(vRecordsNum)) for vRecordID in range(1, vRecordsNum+1): vRecordHandle = vs.GetRecord(vHandle, vRecordID) vRecordName = vs.GetName(vRecordHandle) vMessage = "Database : " + str(vRecordID) + " : " + vRecordName + " : " +str(vRecordHandle) vs.AlrtDialog(vMessage) vFieldsNum = vs.NumFields(vRecordHandle) vFieldsName = vRecordName + " : " for vFieldID in range(1, vFieldsNum+1): vFieldsName = vFieldsName + vs.GetFldName(vRecordHandle, vFieldID) + ", " vs.AlrtDialog(vFieldsName) Quote Link to comment
relume Posted March 15, 2018 Author Share Posted March 15, 2018 Hello I try to clone/merge databases (record format) by python scripting. So far I can copy database definitions by vs.GetFldName, vs.GetFldType, vs.GetFldFlag but I have not seen any possibility to get the default field value (fieldValue), that can be set by vs.NewField(recName, fieldName, fieldValue, fType, fFlag). Is there any known workaround to get this default field value? Many thanks in advance, Quote Link to comment
Pat Stanford Posted March 16, 2018 Share Posted March 16, 2018 Not on a machine where I can access VW right now, but I seem to remember that if you pass the GetField command either a Nil handle or a handle to the record definition then you get the default values back. Quote Link to comment
relume Posted March 17, 2018 Author Share Posted March 17, 2018 (edited) Hello Pat Thank you very much for answering. I had a flawed reasoning so the command vs.GetRField(object_handle, record_name, field_name) works correct, when passing a record handle to it. Although is somewhat tautologous as in this way a handle to the record and the name to the same record has to be given. So the code would be by referencing the code snippet above: import vs vHandle = "" vRecordsNum = vs.NumRecords(vHandle) vs.AlrtDialog("Databases : " + str(vRecordsNum)) for vRecordID in range(1, vRecordsNum+1): vRecordHandle = vs.GetRecord(vHandle, vRecordID) vRecordName = vs.GetName(vRecordHandle) vFieldsNum = vs.NumFields(vRecordHandle) for vFieldID in range(1, vFieldsNum+1): vFieldName = vs.GetFldName(vRecordHandle, vFieldID) vFieldType = vs.GetFldType(vRecordHandle, vFieldID) vFieldFlag = vs.GetFldFlag(vRecordHandle, vFieldID) vFieldValue = vs.GetRField(vRecordHandle, vRecordName, vFieldName) vMessage = "Record : " + vRecordName + " Field : " + str(vFieldID) + " : " + vFieldName + " : " + str(vFieldType) + " : " + str(vFieldFlag) + " : " + vFieldValue vs.AlrtDialog(vMessage) best regards, André Edited March 17, 2018 by relume 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.