Jump to content

DomC

Member
  • Posts

    605
  • Joined

  • Last visited

Everything posted by DomC

  1. The required constants in Python are True, False and None (NIL ist None) I got something like this in one of my python-script-testing, that works. tempHandle1 = vs.LNewObj() tempHandle2 = None objectHandle = vs.CreateCustomObjectPath('Part', tempHandle1, tempHandle2)
  2. In case someone cares Dialog box still not working, but another test with the python module subprocess to open a system window, works instead. A script test to export the classes of the active document to a textfile and open the export folder in a finder windows. This is an example of feature (open a sys folder) wich would be not possible just with the function offered by classic "pascal-vectorscript". import codecs import os.path import os homeDir = os.path.join(os.path.expanduser("~")) Pfad = '{}/Documents/TempVWFiles'.format(homeDir) FileName=vs.GetFName() File = homeDir+'/Documents/TempVWFiles/'+'Klassenliste_'+FileName+'.txt' d = os.path.dirname(Pfad) if not os.path.isdir(Pfad): os.mkdir(Pfad) KlassenAnzahl=vs.ClassNum() f = codecs.open(File, "w", "utf-8") x = 1 while x <= KlassenAnzahl: Klasse = vs.ClassList(x) x= x+1 f.write('\''+Klasse+'\''+',') f.close() vs.AlrtDialog('Die Datei wurde an folgende Stelle gespeichert:'+File) import subprocess import sys path=Pfad if sys.platform == 'darwin': def openFolder(path): subprocess.check_call(['open', '--', path]) elif sys.platform == 'linux2': def openFolder(path): subprocess.check_call(['gnome-open', '--', path]) elif sys.platform == 'win32': def openFolder(path): subprocess.check_call(['explorer', path]) openFolder(path)
  3. Hi It looks that it should be possible to use all functionality of the standard python 3.3 inside Vectorworks. The python package is included inside Vectorworks. Just to check this out with a simple dialogue window i tried to create a python based message windows inside Vectorworks -without any success. Maybe i trie to practice with the wrong example (Dialoge Box) Somehow module os.path.basename fails. Anyone else tried to do this? Example Code which do not work inside/outside a Vectorscript. But it works from the python 3 mac terminal. import sys from tkinter import * def mhello(): pass return mGui = Tk() ment = StringVar() mGui.geometry('450x450+500+300') mGui.title('python tkinter message') mlabel = Label(mGui,text ='my label').pack() mbutton = Button(mGui,text ='ok',command = mhello,fg = 'red',bg='blue').pack() mEntry = entry().pack This code is from a very simple python script. It checks if the classes of the active document are part of a standard class list. I post this here, because posting some code is something that makes it more interesting to read a thread. It shows the code with the working vectorscript alert dialogue. KlassenAnzahl=vs.ClassNum() Standardklassen = ('Standardklasse1', 'Standardklasse2', 'Standardklasse2', 'Standardklasse3', 'Standardklasse4') NichtStandard ='' x = 1 while x <= KlassenAnzahl: Klasse = vs.ClassList(x) istKlasseVorhanden = Klasse in Standardklassen x= x+1 if istKlasseVorhanden == 0: NichtStandard = NichtStandard + ' / '+ Klasse vs.AlrtDialog(NichtStandard)
  4. Wow, a stupid alpha error. (vectorscript is not case-sensitive) Thank you so much! Just to complete, the running code: import vs def Test(): Text = 'Hello Vectorworks.' vs.AlrtDialog( Text+' This should work, or not?') vs.MoveTo(0,0) vs.LineTo(0,500) Test()
  5. Hello I wanted to port some of my Document-Based Pascal Scripts to Python. Not because it ist necessary, just to learn something. I tried just to build a Python example with some commands from the Vectorworks Namespace. def Test(): Text = 'Hello Vectorworks.' vs.AlrtDialog( Text+' This should work, or not?') vs.moveto(0,0) vs.Lineto(0,500) Test() The "AlrtDialog" seems to work. vs.moveto and vs.lineto do not want Many thanks for some ideas! Dom Error Message: Traceback (most recent call last): File "", line 7, in File "", line 5, in in Test AttributeError: 'module' object has no attribute 'moveto'
×
×
  • Create New...