Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About relume

  • Rank

Personal Information

  • Location

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hello Thank very much you for your hints and considering my questions. The command vs.CallTool() is not applicable, because I have to use an allready existent polygon as selection perimeter and do not want any user inteaction. Iterating over every point to check by vs.PtInPoly if it is on/witin the actual polygon is some kind of "brute force", as I have to iterated first over every polygon an then itereate over all points to be checked for each polygon. But it seems that there is no other approach to do it. I wondered if there would be any VW criteria to select objects by a x/y range (select all objects where x/y is >= as xTop/yTop AND x/y is <= xBottom/yBottom) in order to optimise somebit the iteration process by reducing the amount of relevant points to check after in detail if they are within a certain polygon. But unfortunately such numerical/grafical criteria search is not available in VW as it is part of every GIS-tool. By looking again at the VW search criterias I found the "location" critearia. If an object has a given name, it is possible to formulate a search criteria that looks for points/objects that are within the object with the given name: import vs vs.DSelectAll() vs.SelectObj("(INSYMBOL & INOBJECT & (L='LayerToSearchIn') & (LOC='MySelectionPolygon'))"); With this search criteria the solution is much easier (I do not know the details about performance differences) but of course for every polygone to test a name (a temporary unique name) has to be given: import vs def searchPoints_for_MyPolygon(vMyPolygon_handle): # the original name of the object to be processed has to be retrieved vMyPolygon_Name_org = vs.GetName(vMyPolygon_handle) vMyPolygon_Name_temp = 'MyPolygon_temp_unique_name' vs.SetName(vMyPolygon_handle, vMyPolygon_Name_temp) # a temp. unique name has to be given for the case the name = "" for correct selection vSelectionCriteria_Points = "(INSYMBOL & INOBJECT & (L='LayerToSearchIn') & (LOC='"+vMyPolygon_Name_temp+"'))" vPointsFound = vs.Count(vSelectionCriteria_Points) vs.SelectObj(vSelectionCriteria_Points) vs.AlrtDialog("Points found: " + str(vPointsFound)) vs.SetName(vMyPolygon_handle, vMyPolygon_Name_org) # the original object name has to be reassigned vs.DSelectAll() vSelectionCriteria_MyPolygons = "INSYMBOL & INOBJECT & (L='LayerWithMyPolygons')" vs.ForEachObject(searchPoints_for_MyPolygon,vSelectionCriteria_MyPolygons) vs.AlrtDialog('finished') best regards, relume
  2. Hello I am back 😐 to the recurrent problem of finding/selecting points or other 2D objects within an other 2D polygon or polyline. As long the number of points to be selected are small or smaller than the number of the "selecting" 2D polygons, then I can iterate over every point to check if it is inside a "selecting" 2D polygon by "vs.FindObjAtPt_GetObj". But if I have a (very) large number of points and a smaller number of "selecting" 2D polygons the above approach is inappropriate, due to the huge iteration over every point. So I thought I would be possible to use/adopt the polygon selection tool to "embrace" the relevant points (to be found) by a 2D polygon. But actually I can not see any way how to script this – how to get by scripting a given 2D polygon in to the polygon selection tool to "embrace" the relevant points. I would appreciate any idea how to get the problem solved, many thanks in advance, relume
  3. relume

    Viewport Position

    Hello I am using my script for producing many small plats in a batch (moving window on every object) to export each to its own pdf for many years - first in VectorScript and now ported to Python. It works without problems. I do not need to ResetObject() nor ReDrawAll(). In general I do not see any greate difference to your code. The only difference in my script is, that I am using a predefined presentation layer and reusing it for every plat to be drawn and exported. But I do not think that this is the problem. I tried and slightly adapted your code (see attachment) and the only proble that I can see is, that vs.CreateVP() creates a ViewPort-Object with no layer and class activation (they are all set to invisible). So running your code I get also this square with the red cross in it. But when I assign class and layer visibility to active for this ViewPort-Object the bounding box of the viewport change to its real dimensions and location. Thus assigning class and layer visibility is "indispensable" to get the correct result, although the square with the red cross seems to be a temporarily "artifact" with a viewport with all classes and layers set to invisible. Finally the new created viewport has to moved to the page center (or any position) - that is default and is corresponding the manual viewport creation. best regards viewport.vwx
  4. relume

    Viewport Position

    Hello I complete agree with you. I feel all about the same. 🙂
  5. Hello Oh many thanks for your prompt response that helps a lot! http://developer.vectorworks.net/index.php/VS:SetParent vs.SetParent(ObjectHandle, LayerHandle) best regards
  6. relume

    Viewport Position

    Hello perhaps this snippet from a larger script may help: # -- create viewport : move viewport object to page center vs.Layer(vLayerViewPort_name) # selects layer with ViewPort object vViewCenter_x, vViewCenter_y = vs.GetOrigin() # this works as long SheetLayer origin was not altered vViewPort_Rect_center_x, vViewPort_Rect_center_y = vs.HCenter(vViewPort_Object_handle) vViewCenter_x = vViewCenter_x * -1 vViewCenter_y = vViewCenter_y * -1 vDifference_x = (vViewCenter_x-vViewPort_Rect_center_x) vDifference_y = (vViewCenter_y-vViewPort_Rect_center_y) # message("object_process_item : vViewCenter : " + str(vViewCenter_x) + " / " + str(vViewCenter_y) + " | " + str(vViewPort_Rect_center_x)+ " / " + str(vViewPort_Rect_center_y) + " | " + str(vDifference_x)+ " / " + str(vDifference_y)) vObject_type = vs.GetType(vViewPort_Object_handle) if ((vObject_type == 122) or (vObject_type == 3)): vs.HMove(vViewPort_Object_handle, vDifference_x, vDifference_y) best regards
  7. Hello I am wondering if there is an easy assignment command for objects to change layers as it is for classes (vs.setClass or vs.setClassN). Can it be true, that this should be only possible by duplicating the object first (by vs.CreateDuplicateObject) and thereafter deleting the original? In the VW GUI info-Palette with the appropriate pop-list the task seems more as an reasignment than a duplication (or a hidden cut/past operation). Many thanks in advance and best regrads,
  8. Hello Importing many Shape files into a VW document can be very time consuming. So I would like to write a pyhton script, that will take all Shape files from a folder list and import every file into the VW document. On the VectorScript reference page I can find the command "vs.LegacyShapefileImp()" and the description "Use the old UI to import files". There is no example and nor further specification why this is "legacy" and which command is the actual replacement command. Has any body used a new vs command to import Shape files and could therefore reference me the appropriate documentation? Many thanks in advance and best regards, André
  9. Hello So my approach is, also by condoning the issues with the FindObjAtPt_Create (e.g. the function does not search on the objects precise shape but on its bounding box), it the following script (may be it may help others and save time): def object_atPt_list(vPoint_ToSearch, vPoint_ToSearch_Tolerance = 0, vLayers_ToSearch = None, vSelection_Criteria = ''): import vest.base.vw._ vLayer_Active_handle = vs.ActLayer() vLayer_Active_name = vs.GetLName(vLayer_Active_handle) vXorg, vYorg = vs.GetOrigin() vPoint_ToSearch_new_X = vXorg+vPoint_ToSearch[0] vPoint_ToSearch_new_Y = vYorg+vPoint_ToSearch[1] # vs.AlrtDialog('X/Y Org : ' + str(vXorg) + '/' + str(vYorg) + '\n' + 'PointToSearch new X/Y : ' + str(vPoint_ToSearch_new_X) + '/' + str(vPoint_ToSearch_new_Y)) if vLayers_ToSearch is None: vLayers_ToSearch = layers_info_list('visible') vObjects_ToSearch = 0 if vSelection_Criteria != '': vs.DSelectAll() vs.SelectObj(vSearch_Selection_Criteria) vObjects_ToSearch = 2 vObject_Handle_list = list() for vLayers_ToSearch_item in vLayers_ToSearch: vs.Layer(vLayers_ToSearch_item["name"]) vSearch_Container_start = vs.Handle() vSearch_list = vs.FindObjAtPt_Create(vSearch_Container_start, vObjects_ToSearch, 0, vPoint_ToSearch_new_X, vPoint_ToSearch_new_Y, vPoint_ToSearch_Tolerance) # 2 = selected only; 0 = shalow vSearch_list_size = vs.FindObjAtPt_GetCount(vSearch_list) for i in range(vSearch_list_size): vObject_handle = vs.FindObjAtPt_GetObj( vSearch_list, i ) vObject_Handle_list.append(vObject_handle) # vs.AlrtDialog( 'Index: ' + str(i) + '\n' + 'Obj Type: ' + str(vs.GetTypeN(vObject_handle))) vs.FindObjAtPt_Delete( vSearch_list ) if vSelection_Criteria != '': vs.DSelectAll() vs.Layer(vLayer_Active_name) # vs.AlrtDialog ("vest.base.vw.objects.object_atPt_list : vObject_Handle_list : " + str(vObject_Handle_list)) return(vObject_Handle_list) and the called script snippet "layers_info_list" to get a layers list to search in, if the layers list is not provided in the function parameters: def layers_info_list(vVisibility="all"): vLayer_list = list() vLayer_handle = vs.FLayer() vLayer_id = 1 while vLayer_handle != None: vLayer_attributes = {} vLayer_attributes["id"] = vLayer_id vLayer_attributes["handle"] = vLayer_handle vLayer_attributes["name"] = vs.GetLName(vLayer_handle) vLayer_visibility = vs.GetLVis(vLayer_handle) vLayer_attributes["visibility"] = vLayer_visibility vLayer_attributes["scale"] = vs.GetLScale(vLayer_handle) vLayer_attributes["options"] = vs.GetLayerOptions() vLayer_attributes["mode"] = vs.GetLayerRenderMode(vLayer_handle) vLayer_id += 1 if vVisibility == "visible" and vLayer_visibility == 0: # normal vLayer_list.append(vLayer_attributes) elif vVisibility == "visible_all" and (vLayer_visibility == 0 or vLayer_visibility == 2): # normal or grayed vLayer_list.append(vLayer_attributes) elif vVisibility == "grayed" and vLayer_visibility == 2: # grayed vLayer_list.append(vLayer_attributes) elif vVisibility == "invisible" and vLayer_visibility == 1: # invisible vLayer_list.append(vLayer_attributes) elif vVisibility == "all": vLayer_list.append(vLayer_attributes) vLayer_handle = vs.NextLayer(vLayer_handle) return (vLayer_list) best regards
  10. Hello Thank you very much. Yes this is the approach I am considering - although I hopped for a more convenient way. I have addressed the issue with the origin shift already some years ago (see my post (3rd entry) : FindObjAtPt_Create any working example? I have documented the issue with the circle/arc object in the same post (see 4th entry). best regards
  11. Hello Pat Thank you for considering my question. vs.ForEachObjectAtPoint has similiar issues - works only on the active layer and does not enter in grouped objects.
  12. Hello I am still struggling with this very basic geometric search problem. I am looking for an approach to select 2D objects by a 2D point (preferably with a "pick radius") that lays within the objects to be searched/selected or are overlapped by the pick radius. The issues with the vs functions are still the same as reported some years ago: FindObjAtPt_Create any working example? basic but sever issues with the vs.FindObjAtPt_Create functions are: works only on the active layer and not over all layers or a selection of layers (e.g. visible ones) works only if the document origin does not have been moved - that is a very sever issue does not work correctly on arcs and other object types So my question is, are there any alternative approaches now with python to achieve this? Many thanks for any hint and best regards.
  13. relume

    PIL (Python Image Library) for VW 2018

    Hello I wanted to install the "pandas" library and found problems using the Marionette.VerifyOrGetLib() function but also with the above script from DomC that is similar to the Marionette.VerifyOrGetLib() function. Further for both functions/scripts an URL to a specific version of library to be installed is needed. But pip.main() has the possibility to get the right library version for the VectorWorks Python environment (acutally in VW2018 is 3.5.2). I was able to install the library "numpy" with the following command : pip.main(['install', 'numpy', '--target', vPathToMy_VW_PythonExternals_Folder]) But this did not work for the library "pandas" as the appropriate pip.main() command rised an error saying that there is no correct matching version. But by passing an "-q" parameter "pandas" installs correctly: pip.main(['install', 'numpy', '-q', '--target', vPathToMy_VW_PythonExternals_Folder]) Then I tried also to install "pillow" and it installed also correctly (version 5.0.0) with all dependencies. But there is some problem with probing for correct installation. While the lib distribution is called "pillow", the name to retrieve it with pip.main(), testing the existence and for importing the lib has to be named "PIL". For this reason Morionette.VeriyOrGetLib() does not work. So the installed lib "pillow" has to be tested and imported by: importlib.import_module('PIL') So a script that encompass this problem could be as this: import os import sys import importlib import vs appfolder = vs.GetFolderPath(1) appuserfldr = vs.GetFolderPath(12) cmd = 'Python Externals' if (sys.platform == 'darwin'): pos = appfolder.find(':') appfolder = appfolder[pos:] appfolder = appfolder.replace(':','/') pos = appuserfldr.find(':') appuserfldr = appuserfldr[pos:] appuserfldr = appuserfldr.replace(':','/') cmd = appuserfldr + cmd vs.AlrtDialog("path : " + cmd) if not os.path.exists(cmd): os.makedirs(cmd) #libToimport = 'numpy' #libToimport = 'pandas' libToimport = 'pillow' libToimportAlias = 'PIL' try: importlib.import_module(libToimportAlias) except ImportError: import pip pip.main(['install', '--upgrade', '-q', libToimport, '--target', cmd ]) importlib.import_module(libToimportAlias) try: importlib.import_module(libToimportAlias) exit_code = True vs.AlrtDialog('is installed : '+ libToimport) except ImportError: vs.AlrtDialog('not installed : '+ libToimport) Best regards P.S. And not to forget to reference the python search path to "~/Library/Applications Support/VectorWorks/.../Python Externals"
  14. relume

    How to get a list of databases and fields

    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é
  15. Hello Thank you very much for your answers. Yes I used the Name Node for starting my Marionette Network. But original I was scripting a python script to read out different object properties like surface/area etc. by clicking with the mouse on it. In a hurry I wanted to verify with the Marionette Network on different objects in the drawing, if my script is using the correct vs.commands. So ideally I could borrow some code portions of the Marionette Network. So I think I stay for certain uses with scripts ... best regards, André


  • 7150 Riverwood Drive
  • Columbia, Maryland 21046, USA
  • Contact Us | 410.290.5114


  • © 2018 Vectorworks, Inc. All rights reserved.
  • Vectorworks, Inc. is part of the Nemetschek Group.
  • ×