Jump to content
Developer Wiki and Function Reference Links ×

Old Vectorscript


Recommended Posts

I have just been opening some very old files created in I think VW 10. 2017 appears to open no problem but we have some scripts for which I get error message.

 

If I open the plug-in using Textwrangler the following jumps off the screen:

 

            #show dialog here
            question = 'Python module ' + missingLib + ' is not installed. Would you like to download and install it now?'
            res = vs. AlertQuestion(question,'', 1,'','','','') 
            if res == 1 :
                if sys.platform == 'win32': 
                    piploc = 'Python33\Scripts\pip.exe'
                    pathpip = 'Python33\Scripts'  
                    cdpath = os.path.join(appfolder, pathpip)
                    cmdpip = os.path.join(appfolder, piploc)
                    wd = os.getcwd()  
                    if os.path.exists(cmd) and os.path.exists(cmdpip):
                        os.chdir(cdpath)
                        ret_code = subprocess.call([cmdpip, 'install', missngLibURL, '-t', cmd ])
                        if ret_code > 0:
                            vs.AlrtDialog('Module ', missingLib, ' cannot be downloaded.'); 
                            exit_code = False
                        else:
                            exit_code = True
                            sys.path.append(cmd)
                            os.chdir(wd)
                elif  sys.platform == 'darwin':
                    import pip
                    import urllib.request
                    pos1 = missngLibURL.rfind('/')
                    pos2 = missngLibURL.rfind('whl')
                    downloadedfile = missngLibURL[pos1+1:pos2]
                    downloadedfile = downloadedfile+'whl'
                    urllib.request.urlretrieve(missngLibURL, appuserfldr + downloadedfile)
                    ret_code = pip.main(['install', appuserfldr + downloadedfile, '-q', '--target', cmd ])
                    if ret_code > 0:
                        vs.AlrtDialog('Module ', missingLib, ' cannot be downloaded.');
                        exit_code = False
                    else:

 

Anyone advise as to how, what, where "Python module ' + missingLib + "

 

Many thanks

 

Michael

Link to comment
  • 2 weeks later...

Hi Michael,

   The main problem with the script is all the Classic Dialog calls (the ones in this script) are now obsolete. All dialogs must now use Modern Dialog calls. Here's a list of the Classic Dialog calls on the left and the corresponding Modern Dialog calls on the right. If you plan to do all of the edits yourself, you will need to get familiar with the VS Function Reference, which can be found in your VW application folder in the VWHelp>Script Reference folder, or online at http://developer.vectorworks.net/index.php/VS:Function_Reference
 

CLASSIC MODERN
AddButton CreatePushButton, CreateCheckBox, CreateRadioButton
AddChoiceItem CreatePullDownMenu
AddField CreateStaticText, CreateEditText, CreateEditTextBox, CreateEditInteger, CreateEditReal
AddGroupBox CreateGroupBox, CreateCheckBoxGroupBox, CreateRadioButtonGroupBox
AddHelpItem SetHelpText
BeginDialog CreateLayout
ClrDialog ---
DelChoice RemoveChoice
DialogEvent RunLayoutDialog
DrawDialog ---
EndDialog ---
GetChoiceStr GetChoiceText
GetDialog ---
GetField GetItemText, GetMultilineText
GetSelChoice GetSelectedChoiceInfo
InsertChoice AddChoice
ItemSel GetBooleanItem
NumChoices GetChoiceCount
SelChoice SelectChoice
SelField SelectEditText
SetField SetItemText
SetHelpString SetHelpText
SetItem SetBooleanItem
SetItemEnable EnableItem
SetTextEditable EnableTextEdit
SetTitle ---

 

   You'll also need to write a dialog event handler procedure. When you get that far, write back and I or someone else will help you with it. If you want help offline, PM me.

 

HTH,

Raymond

Edited by MullinRJ
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...