Jump to content

ShowWebDlg()


Recommended Posts

Hello
My actually (succesful) approach is, to connect python (import pymysql) to an sql database, query data from this database and do the same with a website. So far that works but this needs a costly infrastructure to run. I am searching a way to directly share data via Session-Variable or at least a JSON download inside the web Dialoge and grab this data with Vectorworks after leaving the dialog. If I would download a file inside the web dialog this file is nowhere, also cookies or session variables are stored encapsulated from the system and also reversed system is encapsulated for the webbrowser. By the way that is good generally for our all security.

I think there must be an undocumented API to directly securely transfer local data between the web Dialog and Vectorworks. Maybe SDK technique has to be used for this?

I'm curious about it.

Link to comment

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.

Edited by PatW
  • Like 1
Link to comment
  • 1 year later...

Hi
My idea is to create a web server, host a dialog there, and exchange data via the web directory of the hosted content. So far, I see the following possibilities:


1. **Dump the site from Vectorworks to a local file.**  
   Local web content is restricted and, as far as I can see, cannot contain cross-references or multiple files. This is for security reasons, as a web application shouldn't control the local file system. One way to address this is by using a local development server (e.g., Python's `http.server`) to serve the content over HTTP, bypassing these restrictions.


2. **Launch an Apache server on macOS.**  
   This works so far; the site is hosted in a machine directory that is accessible with root privileges. It's quite simple to do with a `subprocess sudo apachectl start`. This would work, and the web application could load and write data in the directory. However, this requires root access to start Apache. Or having to manipulate configuration files. 


3. **Launch a web server via Python.**  
   Here, it’s not possible to launch it directly within Vectorworks because the server would block the Vectorworks main thread, as Python’s default HTTP server runs synchronously. 


4. **Launch a Python web server as a subprocess and access the embedded Python in Vectorworks.**  
   This could be possible, but the environment variables in the OS might not handle the embedded Python properly. Explicitly configuring the subprocess environment or using isolated Python installations could help mitigate this issue. However, it's possible that the embedded Python content is designed to run exclusively within Vectorworks, making this option challenging.
bash python3 -m http.server 8080


5. **Installing additional application in the OS.**  
   This is also possible, but the solution should work like a portable standalone application rather than requiring content to be installed into the system. Tools like Docker or portable Python distributions could make this approach feasible without impacting the system setup.


6. **Using an external web application to handle everything.**  
   In this approach, you send a token, the web application processes the data (e.g., sanitizes and validates it), builds the site, and writes results to a database. The local script can then retrieve the results using the temporary token. I’ve used this method for some projects, and it seems very flexible and powerful. However, it requires an external web service and isn’t lightweight at all.

7. Creating one single local web-page
Merging everything in one file would work for pushing the content into the site. Still the issue then, that it is not possible to write something on the disk, which would work with the #2 apache webservice.
 

I know an SDK-developed application could make direct access possible (anyway i never tried this, too much respect from the c++ environment),  even with a non-blocking palette. But still there is the other question of hosting the site on the localhost.

Does anyone have additional ideas for a simple, secure and clean workflow to host the web-content?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...