Jump to content

PatW

Member
  • Posts

    85
  • Joined

Posts posted by PatW

  1. On 8/19/2023 at 11:54 PM, spettitt said:

    At the moment, I've just defined a simple alert dialogue to pop up. If I use the 'Run Script' command in VW and point it at the main.py file, it will execute in VW fine. But obviously now I'll be trying to make more useful things. If I had a script that executed various things in VW, how can I run the script such that I can debug it in PyCharm and see it running in VW as well? Put another way, if the script fails at a certain point when executed in VW, how would I be able to see that problem in PyCharm and sort it?

     

    That could be done by the remote debugger but according to this topic it is not working reliable.

     

    https://developer.vectorworks.net/index.php/Python_Debugging

     

     

    When the script fails you should see the error message poping up in VW that tells you in which function and which line the problem occured.

    Make sure the VW option run scripts in debug mode is enabled.

  2. 1 hour ago, spettitt said:

    I've exported two blank VWX files as VS (with/without) and can't see anything different between them. I'm guessing it's held at app/user pref level rather than file level.

    This file settings are very likely stored hidden in the file data. If it would be stored in a seperate file the prefs would be lost when sharing the vwx with someone.

     

  3. Yes the VWR is a ZIP file.

     

    You could create a batch file that creates the zip with "7Zip" in the Post build event.

     

    This was quickly put together and is untested:

     

    cd C:\Program Files\7-Zip 
     
    7z a "C:\Users\pwink\Desktop\res.zip" "C:\Users\pwink\Documents\DEV\CableTools\CableTools.vwr\DialogLayout" "C:\Users\pwink\Documents\DEV\CableTools\CableTools.vwr\Images" "C:\Users\pwink\Documents\DEV\CableTools\CableTools.vwr\Strings"

     

     

     

     

  4. In the SDK you would use the class IExtensionWebPalette to define  your webpalette and  IWebJavaScriptProvider to register the JavaScript functions which can hand data back to the C++ part.


     

        class YourCustom_JSProvider: public VCOMImmediateImpl<IWebJavaScriptProvider>
        {
        public:
            CableToolWebPaletteJSProvider();
            virtual ~CableToolWebPaletteJSProvider();
    
            virtual void        OnInit(IInitContext* context);
            virtual void        VCOM_CALLTYPE OnFunction(const TXString& name, const std::vector<VWVariant>& args, VectorWorks::UI::IJSFunctionCallbackContext* context);
           
        private:
            IWebPaletteFrame*    fWebFrame;
            
        };

     


     

        // --------------------------------------------------------------------------------------------------------
        class YourCustom_JSProviderCableToolWebPalette : public VCOMImmediateImpl<IExtensionWebPalette>
        {
            DEFINE_VWPaletteExtension;
            DEFINE_VWProtection;
        public:
            CableToolWebPalette(CallBackPtr);
            virtual ~CableToolWebPalette();
    
            virtual IEventSink* VCOM_CALLTYPE    QueryEventSink(const TSinkIID& iid);
    
            virtual TXString    VCOM_CALLTYPE GetTitle();
            virtual bool        VCOM_CALLTYPE GetInitialSize(ViewCoord& outCX, ViewCoord& outCY);
            virtual TXString    VCOM_CALLTYPE GetInitialURL();
            
    
        private:
            CableToolWebPaletteJSProvider            fJSProvider;
        };

     

     

    Register the function:
     

    void YourCustom_JSProvider::OnInit(IInitContext* context)
    
        context->AddFunction( "VW_UpdateData" );

     

    When it is triggered in the webpalette this callback is executed:

     

    void YourCustom_JSProvider::OnFunction(const TXString& name, const std::vector<VWVariant>& args, VectorWorks::UI::IJSFunctionCallbackContext* context)

     

    Unfortunately there is no doc about this on the vw wiki.

    • Like 1
  5. You are right from a user view it makes more sense when the error appears for the first line. But in Python a statement can go to the next line when it is within brackets.

    So the python engine realizes that something is wrong when it suddenly sees a declaration in the next line.

     

    This is valid for example:

     

    print ( "a"
            + "b")

     

    • Like 2
  6. 
    def callback(h):	
    	sym = vs.GetRField(h, "BrxHoist", "SymbolUsed")
    	
    	symH = vs.GetObject(sym)	
    	
    	if symH:
    		val = vs.GetRField(symH, "HoistObjectData", "Manufacturer")
    		vs.SetRecord(h,"HoistObjectData")
    		vs.SetRField( h, "HoistObjectData", "Manufacturer", val)
    
    	
    vs.ForEachObject(callback, "(R IN ['BrxHoist'])")

     

    Here is a little scrip which I quickly put together. It attaches the record to each hoist and only fills in the manufactur.

    Could be done better but I hope this works for you.

     

    • Like 1
  7. Within VectorWorks\VW28.0.2b(671358)_64\Plug-Ins\Marionette.vwr\Scripts\ (vwr is a zip archive) you can find the Marionette.py

    Put this one in the pycharm project and then use import Marionette in the script, then all the errors should dissappear.

     

    The same applies for the vs.py that you can find at the end of this page.

    Search for "IDE and Debugging Python Scripts"

     

    https://developer.vectorworks.net/index.php/Python

     

    Another trick to make development easier is to add the path of your custom node py to the script option (Tools->PlugIns->Scipt options..) and then import the py module into the actial marionette node instead of copying it everytime from the IDE.

    • Like 4
  8. I also see no other way than RunTemp tool.

     

    You pass in the IID like this:

     

        gSDK->RunTempTool( Your_VWExtensionToolClass::_GetIID());

     

    You could write the data of the tool into a static class member that you acces then from the menu command or which is saver you finsih the job in the ::PointAdded method of the VWExtensionTool.

     

     

     

  9. Hi,

     

    when editing vwstring files Git shows the message "no changes found" in the diff view, I know this has to do with the utf-16 encoding but all the solutions of stack overflow didnt help so far.

     

    Did anyone here figure out how to fix this?

     

    regards,

    Patrick

  10. What you could try is to put it temporaly in a folder before exporting and see if ExportResourceN maintaince the structure.

     

    Another solution I can think of is opening the lib file and create the folder.

    Unfortunately this can not be done silently so the user will see the file poping up for a second.


     

           if ( gSDK->OpenDocumentPath( fileID, true))
            {
    
                // DoStuff
                
                gSDK->DoMenuName("Save", 0);
                gSDK->CloseDocument();            
                gSDK->HandlePendingUpdatesAndActivates(); //workaround for bug in OnFileContent: to trigger closedocument
            }

     

  11. When I want to see the implementation of a SDK function I always need to open the cpp file by the explorer like "..VW2023_WIN64\SDKLib\Source\VWSDK\VWFC\Tools\ProgressDlg.cpp".

     

    Does any one know the trick to jump directly with visual studio to the source like you can do on the local cpp files?

    I tried it with adding the directory to "VC++ Source Directories" and "Additional Include Directories" but that didn't help.

     

    regards,

    Patrick

     

×
×
  • Create New...