Jump to content

Patrick Winkler

Member
  • Posts

    225
  • Joined

  • Last visited

Everything posted by Patrick Winkler

  1. Thanks pat. I needed some attempts to get back from the str to the vs.Handle. The cells get filled with this code: h = vs.WSScript_GetObject() h_str = str(h) vs.WSScript_SetResStr(h_str) Then another script iterates trough all objects and compares the handle strings: def get_handle_from_str (h_str): h_dict = {} # key: handle_str val: handle def collect_handles(h): nonlocal h_dict h_dict[str(h)] = h vs.ForEachObject (collect_handles, 'All') try: h = h_dict [h_str] except KeyError: print ('Handle could not be found.') h = None print (h_dict) return h # EXAMPLE h = get_handle_from_str ('AEC62080') vs.SetSelect (h) It's kind of unpracticle and carries the risk if inconsistency but it works. ws_test.vwx.zip
  2. Hi Matt, any Python-IDE can do this. You can either put the vs.py next to your other py modules or better add a search path to the project that links to a folder where the vs.py is located. Then you have to import it in the modules where vs-functions are called. import vs I use pydev for eclipse. The search path can be added in the project properties.
  3. The only workaround I know is using a dropdown menu instead of the radiogroup. regards
  4. Luckily there's a VectorScript function for calling python scripts: http://developer.vectorworks.net/index.php/VS:PythonExecute Simply wrap it up the Python code and call it with DoScript. vector_script = "PythonExecute( 'import vs; vs.AlrtDialog("This is a Pythonscript wrapped in a Vectorscript!" )');"
  5. Hi Marissa, sorry I could have mentioned that I tried reading the yellow marked cell with GetWSSubrowCell but it returns me nothing. My goal is to get the handle to the door-row from the worksheet so that I can read data from the ws in write it in a record of the door. regards
  6. Unfortunately it only supports VectorScripts.
  7. Hello, I could not find a way to get the handle of a workssheet cell. Maybe you have an idea. regards
  8. This can be done with the ActiveX interface. I have problems to get it work but you could give it a try since it only takes some minutes. First start VW as Admin once to register the ActiveX interface. Then you can create a JavaScript that uses the COM-Objects for Example. var fVWCore = new ActiveXObject("VectorWorks.Core"); var fVWScript = new ActiveXObject("VectorWorks.Script"); var fullFilePath = "C:\\Users\\????\\Desktop\\Sample VWX Files_2016\\"; var fileName = "sample_A.vwx"; fVWCore.OpenDocument(fullFilePath + fileName, false); fVWScript.DoScript("AlrtDialog('hello from the java script');"); Use the 'Windows Based Script Host ' to execute the script. Tell us if it works. regards
  9. It's actualy not as complicated as I rembembered: Here is a python example that fills a ThumpPopUp with hatches: def get_hatches (): ''' Get a tuple with the name of all hatches in the actual Doc. ''' hatch_nams = [] num = vs.NameNum() for i in range (1, num + 1): # IMPORTANT: index must start at 1 here! name = vs.Index2Name(i) h = vs.GetObject(name) if vs.GetTypeN (h) == Obj_Type_Enum.hatch_defini: # Here you have to check for Symbol-Definis (Type: 16) hatch_nams.append(name) return tuple (hatch_nams) # Call this function at the initialization of the dialog (Handler event: 12255) def fill_hatch_popups (): # Fill the Controls with all hatches in the doc for h_nam in get_hatches(): vs.InsertImagePopupObjectItem(dialogID, kPD_Hatch_Hauptg, h_nam) # You can read the selected value with: hatch_hauptgeb = getImagePopupSelText(kPD_Hatch_Hauptg) Also take a look at the example projects in the wiki: http://developer.vectorworks.net/index.php/Main_Page regards
  10. of course, you can create your own command, this can easily cost you a day as a beginner. Maybe it's less of an effort to just click on the button in the oip? Do you need a dialog for selecting the new Symbol everytime? If it's always the same Symbol you could write the name into an TextFile. Here are some hints: - Get the Sym location from the selected symbol instance: http://developer.vectorworks.net/index.php/VS:GetEntityMatrix - For the Sym Selection in the Dialog you need a Custom Thumb PopUp, I see if I can get an example tomorrow: http://developer.vectorworks.net/index.php/VS:CreateCustThumbPopup - Delete the instance with DelObject (handle) - Replace it by the new Symbol: http://developer.vectorworks.net/index.php/VS:Symbol regards
  11. Hi, you can assign a shortcut to the command Modify- > Convert- > Replace with Symbol... . this will not work. you can not check the order in which the symbols have been selected. regards
  12. Hello A_WIese, that looks really interesting. Could you be more precise about your problem?
  13. Also take a look at the Surface Array(no Marionette) command: I created a little example that comes close to your window: surface_array_demonstration.mov
  14. Hi Sebastien, I guess VW 17 does not respect escape sequences because it can have bad side effects. If you provide a win path for example folder\ronald >> folder onald You can print the raw string with the command: s = StringFromTheField print (repr (s)) If the result contains '\\r' instead of '\r' the escape sequence was disabled. Just replace it with '\r' to make it work again. s = 'A\\rB' s = s.replace ('\\r', '\r') regards
  15. I miss the Sort by Author Option in the 'Sort By' menu at the top right.
  16. Hello Markus, I guess the funtion you need is VS:SetPrefReal in combination with the index 1320. Default Render Mode Perspective Distance : 1320 http://developer.vectorworks.net/index.php/VS:Function_Reference_Appendix#Appendix F - PreferenceSelectors However the function throws an error with that index. regards
  17. Hello, can some one tell me how to assign a text style from the resource manager to an text object. SetTextStyleRefN() needs a style reference id which I have no clue how to get. Edit: ok sry, I passed the wrong params. In case some one needs to know how it works: h = vs.FSActLayer( ) style_id = vs.Name2Index ('Verdana Test') vs.SetTextStyleRef (h, style_id)
  18. You don't have to create a new node from nothing. I simply hijacked the any-node. @Marionette.NodeDefinition class Params(metaclass = Marionette.OrderedClass): this = Marionette.Node( 'UnitsPerInch' ) v = Marionette.PortOut() v.SetDescription('The resulting value') def RunNode(self): fraction, display, format, upi, name, squareName = vs.GetUnits() self.Params.v.value = upi
  19. Hello, the function vs.GetUnits() returns a variable that tells how many units are one inch: fraction, display, format, upi, name, squareName = vs.GetUnits() You can create a node that returns this value. The rest should be straight forward. regards, Patrick
  20. Sorry but this will lead to an infinite loop. Even with a thread I had no succes. When the main thread is blocked the dialogs and I guess the interactive functions are also blocked. I doubt that there is a working solution. import vs from time import sleep import threading wait_for_thread = True class GetPtThread (threading.Thread): def __init__ (self): super().__init__() def run (self): ''' ''' def callback (p): global wait_for_thread vs.AlrtDialog('You slected {}'.format( p )) # Call this at the end wait_for_thread = False vs.GetPt(callback) vs.AlrtDialog ('Thread Finished') # Start ne Thread t = GetPtThread() t.start() # Let the main thread wait until this thread has finished. timeout_secs = 10 t.join(timeout_secs) #=============================================================================== # cnt = 0 # while wait_for_thread: # sleep(5) # cnt += 1 # # if cnt > 4: # vs.AlrtDialog(wait_for_thread) # break #=============================================================================== vs.AlrtDialog('Script Finished.')
  21. I never used this functions but the docu of getpt() says: I guess you have to create a global flag that controls when the execution can go on. wait = True vs.GetPt () while wait: # Change wait to False in the callback of GetPt pass ... Maybe this works for TrackObj.
  22. Hi roberto, please tell us what OS and VectorWorks version you use.
  23. Hi herbie, I think realising that in pure Marionette is very complicated. (we need recursion!) Here is a node which creates a random range where no neighbouring numbers are equal. random_range_custom.vwx
×
×
  • Create New...