Jump to content

twk

Member
  • Posts

    862
  • Joined

  • Last visited

Posts posted by twk

  1. the path has to be absolute when executing inside vectorworks. Not:

    filename = "output.csv"

    leaving it as "output.csv" is telling Vectorworks' python interpreter to save it the installation directory of vectorworks.

    Try specifying a full path to another location eg.

    filename = "C:\Temp\output.csv"

     

     

    Also look at DataFrames for python using the pandas module. It has better functionalites for Data Wrangling.

    You'll need to write your own module for converting a worksheet table to a pandas dataframe, then once its in dataframe format, you can do many things with that dataframe. Export to csv, xls, json, etc

     

    • Like 1
  2. 1 hour ago, Jesse Cogswell said:

    There is a fantastic chance that you don't need the file structure and I just needed to restart VW.

     

    My testings have shown you dont actually have to restart VW. You just need to open the Plugin Manager, navigate to your plugin/tool, then select "edit definition" or "edit script", then close it, then exit plugin manager.

  3. 4 hours ago, MullinRJ said:

    @tui_k,

       Using your code on a Mac I get :

     

    image.png.a3071c3ddf7edc639075aa4429726b3b.png

     

    but I used: vs.CreateRadioButton2(dialog_id, 6, 'Push Button', layer_icon_path)

    instead of: vs.CreatePushButton(dialog_id, 6, 'Push Button')

     

       Perhaps it's a Mac/PC thing. I'll try on a PC, but it may take a while.

     

    Raymond

     

     

     

    Much appreciated @MullinRJ. So it looks like it is a windows issue. I've also wondered whether any of the native vectorworks tools implemented that checkbox/radio item image control. 

    Thanks again I shall open a bug ticket for windows.

  4. Vectoworks ships with its own version of Python in a python folder located in the program files (for windows). eg location below:
    C:\Program Files\Vectorworks 2023\Python39

    so in the windows command prompt you navigate there using:
     

    cd "C:\Program Files\Vectorworks 2023\Python39"

     

    then run this:

    python -m pip install pandas

     

    Note
    it's recommended that you upgrade pip before installing pandas by running this command (in my examples below my vectoworks install location may be different from yours):
     

    C:\Program Files\Vectorworks 2023\Python39>python -m pip install --upgrade pip

     

     

    then you'd install pandas:
     

    C:\Program Files\Vectorworks 2023\Python39>python -m pip install pandas

     

    • Like 3
  5. https://developer.vectorworks.net/index.php/VS:CreateCheckBox2

    https://developer.vectorworks.net/index.php/VS:CreateRadioButton2

     

    These two dialog control items were added in VW2023, however setting an icon for their display doesn't seem to be working.

     

    Previous similar dialog items icons were able to be set by utilising the resource path in the .vwr location, however it doesn't seem to be working for these ones. And also, I can't seem to see an example of this type of control in any vectorworks' dialogs in any of their stock tools/commands.

     

    If you look at my code below, the vs.CreateImagePushButton dialog control seems to work by using the icon path 'Vectorworks/Images/Standard Images/Layers.png', however that same path doesnt work for either CreateCheckBox2 or CreateRadioButton2. Anyone have any ideas before I open a bug ticket? @JBenghiat @MullinRJ @Jesse Cogswell @Vlado @Pat Stanford

     

    import vs
    
    layer_icon_path = 'Vectorworks/Images/Standard Images/Layers.png'
    SetupDialogC = 12255  # A predefined constant value that is passed to the dialog event handler subroutine when a modern custom dialog is initially displayed onscreen.
    SetdownDialogC = 12256  # This constant is passed to the event handler routine to signal dialog setdown.
    ResizeDialogC = 12611  # This constant is passed to the event handler routine to signal the dialog has been resized.
    DisplayDialogHelpC = 12916  # This constant is passed to the event handler routine to signal the dialog that it should display its contextual help using the help string given by the Contextual Help Manager menu.
    DialogTimerEventMessageC = 13028  # This constant represents the message that is sent periodically to a dialog handler after it has been registered to receive timer events.
    LeftButtonC = 12605  # This constant is used as a control ID when a button must appear in the lower left corner of a dialog.
    
    dialog_id = vs.CreateLayout('Dialog Icons Test', False, 'Ok', 'Cancel')
    
    vs.CreateCheckBox2(dialog_id, 5, 'Image TextBox', layer_icon_path)
    vs.CreatePushButton(dialog_id, 6, 'Push Button')
    vs.CreateImagePushButton(dialog_id, 7, 50, layer_icon_path)
    
    vs.SetFirstLayoutItem(dialog_id, 5)
    vs.SetBelowItem(dialog_id, 5, 6, 0, 0)
    vs.SetBelowItem(dialog_id, 6, 7, 0, 0)
    
    def dialog_handler(item, data):
        if item == SetupDialogC:
            pass
    
        elif item == 1:
            pass
    
        elif item == 2:
            pass
    
    vs.RunLayoutDialog(dialog_id, dialog_handler)

     

    image.png.d8de144e690d5115e2814fe24ae662e5.png

  6. As others have stated, we;re limited with the vectorscript/python implementations provided by vectorworks.

    What I have done with other similar plugins, is a menu item that runs a script looking for changes across the document and updating relevant/linked plugins as needed.

  7. 1 hour ago, Vlado said:

     

    Oh wow, I haven't heard about this. Can you enter a JIRA with your workspace file that causes this? I wasn't able to reproduce it immediately.

    or you can send me the file over to vstanev@vectorworks.net, and I'll file it, to get fixed

     

    Yep have filed a bug (VB-196628), but it wasn't just my workspace.

    Even with the stock workspaces, once you edit the stock workspace and nest any of those tools (doesnt have to be all of them) it will cause the crash when exiting the Edit contours mode. I'll try and find time for a demo video illustrating.

     

    image.png.7d818f080cf8ae83eaedcf74fab467fc.png

     

  8. Well well well.. just spent the last 3 hours diagnosing what was happening and causing the crash.

    Turns out it wasn't:

    - a converted workspace

    - custom short cut keys for my workspace

    - or any custom plugins I had

     

    The Trial and Errors

    Before I unveil the culprit and the solution, share in my grief that which I painstakingly tried. (Side note, there were other anomalies found that were causing other crashes) :

    1. Converted multiple stock workspaces (ANZ, ANZ-BIM)

    2. Removed all shortcut keys

    3. Editing Tools and Menu Items to add our set of custom office shortcut keys

    4. Re-organised icon positioning and stacking within palettes to match our previous office workspace setouts.

     

    Test actions to trigger the crash

    1. Editing or just entering the contours space, for the -> Grade Limit Site Modifier's 'Define by Contours'

    2. Upon exiting, Vectorworks crashes

    The culprit(s):

    - Stacking Tools used in this mode (Reshape, Split, Trim, Clip, Pan, Zoom, and others).

    1. If these tools are stacked in my workspace it will cause the crash. They must be at the top most level in the tool palette

    2. When you're in this contour edit mode of the Grade Limits site modifier, you can see that these tools are not stacked beneath anything

    image.png.319e28a27865a52d2c9ca3949b039b71.png

     

     

    The solution:

    After all that testing, all I had to do was make sure that my custom workspace had these particular tools 'unstacked'. Ie not nested under another tool.

     

    If anyone has a spare moment can you test this by in your own workspace, nest one of these tools (any in my experience) and see if it crashes. 

    @Matt Panzer, @Vlado, it looks like the Contour Edit Palette above is causing some issues, I shall file a bug.

     

     

     

    • Like 4
  9. Apologies looks like there was an extra line after the 'while' call. correct below:

     

    # Define a function to list the names of all sheet layers in the current document
    def list_sheet_layer_names(excluded_layer_names=None):
        """
        @type filter_layer_names: exclusive layer names list ie, only these layers to be returned
        """
        layer_names = []
        hLayer = vs.FLayer()
    
        # Use a while loop and the NextLayer() function to iterate through all the sheet layers in the document
        while hLayer != None:
            if vs.GetObjectVariableInt(hLayer, 154) == 2:
                layer_name = vs.GetLName(hLayer)
                if excluded_layer_names:
                    if layer_name not in excluded_layer_names:
                        layer_names.append(layer_name)
                else:
                    layer_names.append(layer_name)
            hLayer = vs.NextLayer(hLayer)
    
        return layer_names

     

    • Like 1
  10. You know what, I misunderstood your question.

    You're wanting an excluded list.

    We'll revise the 'list_sheet_layer_names' function that accepts a list of sheets to be 'excluded' as a parameter.

     

    # Define a function to list the names of all sheet layers in the current document
    def list_sheet_layer_names(excluded_layer_names=None):
        """
        @type filter_layer_names: exclusive layer names list ie, only these layers to be returned
        """
        layer_names = []
        hLayer = vs.FLayer()
    
        # Use a while loop and the NextLayer() function to iterate through all the sheet layers in the document
        while hLayer != None:
            layer_names.append(hLayer)
            if vs.GetObjectVariableInt(hLayer, 154) == 2:
                layer_name = vs.GetLName(hLayer)
                if excluded_layer_names:
                    if layer_name not in excluded_layer_names:
                        layer_names.append(layer_name)
                else:
                    layer_names.append(layer_name)
            hLayer = vs.NextLayer(hLayer)
    
        return layer_names

     

    then when you run the iteration, you provide the list of sheet names you want excluded:

     

    # Iterate through all sheet layers in the current document
    # Say you want to exclude sheets 01, 05, 10, 12
    for layer in list_sheet_layer_names(['01', '05', '10', '12']):
    
        # Define criteria strings to find title blocks and viewports on the current layer
        titleblock_crit_str = f"(((L='{layer}') & (PON='Title Block Border')))"
        viewports_crit = f"(((L='{layer}') & (T=VIEWPORT)))"
    
        # Use the get_objects_from_criteria() function to get lists of title blocks and viewports on the current layer
        titleblocks = get_objects_from_criteria(titleblock_crit_str)
        viewports = get_objects_from_criteria(viewports_crit)
    <<< RESET OF CODE >>

     

     

     

  11. Good point @Pat Stanford. My workspace is probably converted from 2021 if I can recall correctly.

     

    It's strange though, editing the contours and updating the site model works fine if I'm on the Architect workspace, as soon as I change the workspace to my converted one, and then try to edit/update the contours through the grade limit, it crashes. And this is all within the same session.

     

    I would've thought the tools or the operations that run in the background are not dependent on anything stored in the workspace.

    But all good, will re-do a fresh workspace, it is about time.

  12. there was a mistake in the indent blocking for the last line of the loop, the hLayer = vs.NextLayer(hLayer) shouldn't be nested in the else portion. Fixed below:
     

    # Define a function to list the names of all sheet layers in the current document
    def list_sheet_layer_names(filter_layer_names=None):
        """
        @type filter_layer_names: exclusive layer names list ie, only these layers to be returned
        """
        layer_names = []
        hLayer = vs.FLayer()
    
        # Use a while loop and the NextLayer() function to iterate through all the sheet layers in the document
        while hLayer != None:
            layer_names.append(hLayer)
            if vs.GetObjectVariableInt(hLayer, 154) == 2:
                layer_name = vs.GetLName(hLayer)
                if filter_layer_names:
                    if layer_name in filter_layer_names:
                        layer_names.append(layer_name)
                else:
                    layer_names.append(layer_name)
            hLayer = vs.NextLayer(hLayer)
    
        return layer_names

     

    • Like 1
  13. revised list_sheet_layer_names below, added option to provide a list of layernames you want to only be returned.

     

    # Define a function to list the names of all sheet layers in the current document
    def list_sheet_layer_names(filter_layer_names=None):
        """
        @type filter_layer_names: exclusive layer names list ie, only these layers to be returned
        """
        layer_names = []
        hLayer = vs.FLayer()
    
        # Use a while loop and the NextLayer() function to iterate through all the sheet layers in the document
        while hLayer != None:
            layer_names.append(hLayer)
            if vs.GetObjectVariableInt(hLayer, 154) == 2:
                layer_name = vs.GetLName(hLayer)
                if filter_layer_names:
                    if layer_name in filter_layer_names:
                        layer_names.append(layer_name)
                else:
                    layer_names.append(layer_name)
                    hLayer = vs.NextLayer(hLayer)
    
        return layer_names

     

    • Like 2
×
×
  • Create New...