-
Posts
225 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Articles
Marionette
Store
Everything posted by Patrick Winkler
-
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
-
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.
-
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!" )');"
-
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
-
Unfortunately it only supports VectorScripts.
-
Hello, I could not find a way to get the handle of a workssheet cell. Maybe you have an idea. regards
-
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
-
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
-
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
-
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
-
New to scripting need advice on my current script
Patrick Winkler replied to A_Wiese's topic in Marionette
Hello A_WIese, that looks really interesting. Could you be more precise about your problem? -
Please help me figure out this curtain wall/window/skylight?
Patrick Winkler replied to Hassan Raza's topic in Marionette
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- 3 replies
-
- 1
-
- windows
- curtain wall
-
(and 1 more)
Tagged with:
-
Trouble multi-line field in a plugin obect since VW2017
Patrick Winkler replied to SebastienB's topic in Python Scripting
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 -
-
Yes
-
Script for setting a custom perspective distance?
Patrick Winkler replied to Markus Barrera-Kolb's topic in Vectorscript
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 -
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)
-
Get area in square feet independent of document units
Patrick Winkler replied to jcbarnes75's topic in Marionette
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- 4 replies
-
- 1
-
- marionette
- document units
-
(and 2 more)
Tagged with:
-
Get area in square feet independent of document units
Patrick Winkler replied to jcbarnes75's topic in Marionette
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- 4 replies
-
- marionette
- document units
-
(and 2 more)
Tagged with:
-
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.')
-
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.
-
voronoi familiar colorful cubes
Patrick Winkler replied to DomC's topic in Resource Share - Marionette
Hi roberto, please tell us what OS and VectorWorks version you use. -
List of random numbers where no following number is equal
Patrick Winkler replied to herbieherb's topic in Marionette
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