Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by MaxStudio

  1. First let me thank you for your response. Way back in high school I took pascal and early in college took C++ beyond that I'm self taught writing scripts mostly for vectorworks and a few other programs. So recently I was told by a sales rep that python would be the future for vectorworks. This has led me to this point where I'm attempting to get a grasp on python. Using the internet I'm trying to teach myself enough to get by and trying to keep my examples small so I don't attempt to take on too much at one time or overwhelm other forum users with an exorbitant amount of info. As for IDE, I use TextWrangler to write most of the scripts. I can run python in that but, I can't run anything written specifically fro Vectorworks. Vectorworks has been a pain to test the python code due to the fact that I have to restart it everytime I change a file i am importing. Unfortunately, at this stage I'm dealing with a lot of trial & error. (thus my quote in my signature) If you have any other near free solutions for IDE I would appreciate it. I really appreciate all your help. Thank You!
  2. ok changed all the vs.Message() to vs.AlrtDialog() At first I tried just replacing the vs.Message() with vs.AlrtDialog() and still only got one alert dialog saying hello world example.py import vs from test import myclass def plugin(): obj = myclass return obj.runme() plugin() def plugin2(): vs.AlrtDialog('Ive made it this far') plugin2() test.py import vs class myclass: def runme(): vs.AlrtDialog("hello world") It wasn't until I added the plugin2() that it gave me: hello world in one alert box and Ive made it this far in a second alert box but it didn't only run once... it ran 3 times! huh!? :eek:
  3. Python does work with single and double quotes. I've actually gotten the import to work. I have updated the example.py as follows: import vs from test import myclass def plugin(): obj = myclass return obj.runme() vs.Message("I've made it this far") plugin() test.py is as follows: import vs class myclass: def runme(): vs.Message("hello world") so at this point my code produces hello world but for some reason it does not finish the plugin function it seems to skip the vs.Message("I've made it this far") Any ideas why? maybe if I move the vs.Message after I call plugin()...
  4. Ok here's my latest issue: I added the Project folder /Macintosh HD/projects/project02 to the script options>environment paths In the project02 folder are 3 files: example.py test.py __init__.py example.py code: import vs from test import myclass def plugin(): obj=myclass() obj.runme() vs.Message("I've made it this far") plugin() test.py code: class myclass: def runme(self): vs.Message("hello world") I would expect the output to be: hello world I've made it this far but I only get: I've made it this far any ideas why it's not running the runme() from myclass()?
  5. ok seems i was able to get it to work i made a small change in example.py as follows: import sys sys.path.append('/Macintosh HD/projects/project01') from test import myclass I thought import test.myclass was another way of saying from test import myclass but I guess it had a problem with it. I notice when I import myclass it runs the runme def. I assumed that it would import the def but not run it immediately. I guess I was wrong.
  6. I'm playing around with importing into python. All my work is in a folder on my hard drive at the following location: /Macintosh HD/projects/project01 In the project01 folder are 3 files: example.py test.py _init_.py I'm attempting to import information from text.py into example.py test.py contains the following: class myclass: def runme(): print "hello world" example.py contains the following: import sys sys.path.insert(0, '/Macintosh HD/projects/project01') import test.myclass When I run my code it tells me ImportError: No module named myclass Any idea why this is happening? Am I going about this the wrong way?
  7. I have a question about importing into python. With vectorscript we used the $include method when we wanted to import an external file {$INCLUDE Macintosh HD:include:myfile.px} adding the '.px' allowed me to lock the file in vectorworks and it would no longer need the external reference file when I ran the plugin. Is this possible in python? or will i always need to have the multiple files in a directory to import? I could keep all the files I need to import on a server but, I would rather just get the plugin working, compile it, lock it and only have one file to deal with in the end. Does that make sense? and is it possible? Thanks Derek
  8. JOSH! That was the issue. I was so wrapped up in whether or not I was using python correctly I didn't realize I was making a simple mistake in the function. The rectangle has been drawn. Thank You. Thanks also to Dieter for your help
  9. Thanks Josh I'll just keep testing it and see what I can accomplish.
  10. length = vs.PLineLength My code is as follows: def Example(): length=vs.PLineLength width=vs.PBoxWidth x = 0 y = 0 vs.Rect(x,length,y,width) Example() You are saying it's creating the plugin object container using the length and width parameters but, it's not actually drawing the rectangle?
  11. What I posted was the entire code: def Example(): length=getattr(vs,'PLineLength') width=getattr(vs,'PBoxWidth') x = 0 y = 0 vs.Rect(x,length,y,width) Example() Its just a simple rectangular plugin object that creates a rectangle. I want to specify the line weight/pattern/color within the plugin but, the following does not seem to work: def Example(): length=getattr(vs,'PLineLength') width=getattr(vs,'PBoxWidth') x = 0 y = 0 vs.FillPat(1) vs.PenSize(4) vs.PenPat(2) vs.PenFore(255) vs.Rect(x,length,y,width) Example() I've also tried tried applying a handle to the new object but, that didn't seem to work either def Example(): length=getattr(vs,'PLineLength') width=getattr(vs,'PBoxWidth') x = 0 y = 0 vs.Rect(x,length,y,width) #LNewObj found in Document List Handling h=vs.LNewObj() #SetLW found in Object Attributes vs.SetLW(h, 4) vs.SetFPat(h,1) vs.SetPenFore(h,255) Example() which didn't seem to work either.
  12. Setting the attributes from the attribute palette is not working. All i see are the six handles of the object. I really want to be able to set my line weight/style/color from inside the plugin.
  13. I'm sorry, I'm confused by your explanation. at the beginning you state that I use getattr(vs,'PLineLength') but, in your example you do not show that at all. But, I have attempted using it as follows: def Example(): length=getattr(vs,'PLineLength') width=getattr(vs,'PBoxWidth') x = 0 y = 0 vs.Rect(x,length,y,width) Example() Good News! it draws the object and allows me to manipulate it via the OIP Bad News... it's invisible. It has no line weight, fill, or color. I need to find a way to apply attributes to the newly created object.
  14. I've been scripting with vectorscript for a while but, I'm new to python. in vectorscript I would retrieve a parameter from the OIP as follows: LineLength:=PLINELENGTH; How do I go about this in python? If possible, could someone provide me with a simple example of creating a rectangular plugin object that allows me to change the Width & Height of the rectangle via the OIP? Is python meant to phase out vectorscript completely in the future? Thank you Derek
  15. Hey thanks for the great suggestion guys. I was really hoping there was a quick way to reference a point on a wall, type in a distance i could lock and then draw a new wall offset from there. I believe Jim's suggestion is the closest to what I was looking for.
  16. I want to draw one wall a specific distance (5'-0") off another wall. What's the simplest way to do this? Thanks
  17. Has anyone had any experience using aligndistribute2d? I was researching it and wasn't sure if it's available through vectorscript... any ideas? Thanks, Derek
  18. Thats unfortunate, Thanks for your help Jim.
  19. I want to select all objects that are rotated 90 degrees. I can't seem to find this in the custom selection tool. Does anyone know how I can accomplish this? Thanks in advance. Derek
  20. I know I can join two lines by selecting them and then clicking join, but is there a way that i can select, lets say, 3 horizontal lines (of different lengths) and join them to a vertical line? Thanks Derek
  21. that simple... thanks!
  22. Item is an integer that can be 1,2,3,4,5 or 6 If I want items 1 through 3 and item 6 to do the same thing how can I write that? I know I can use 1..3 for items 1 through 3, but how do I also include item 6 so i can condense the following code? CASE item OF 1..3: BEGIN { do procedure A } END; 4..5: BEGIN { do procedure B } END; 6: BEGIN { do procedure A } END; END; Thanks
  23. If I print and then attempt to save Vectorworks crashes... does anyone else have this issue? This is not a new issue... I've just been dealing with it for a long time. Mac OSX 10.5.8 VW 2008 SP3 (Build 88670) Plotter: Canon iPF755 Version 1.20 Thanks, Derek
  24. Raymond, Thank you, I was originally using Num2StrF(). Your suggestion to use Num2Str() has solved my problem. Marteen, I attempted to convert the real to an integer first and it remained in the dimension form. Jonathan, The fields I'm using to do the calculations are Dimensions. The field I'm using to display my calculation is Static Text. Therefor, I needed a way to convert the dimension to a real number. Derek
  25. I have a variable that I want to display in the object info palette. For instance, the value of the variable is 9. I set up a static text and use a setfield to display the 9 in the OIP. For some reason the 9 is displayed as 9" rather than 9. If I change the variable to 12 it displays 1'-0". How do I get it to display 12 instead of 1'-0"? Thanks, Derek


7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114


© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

  • Create New...