Jump to content

MaxStudio

Member
  • Posts

    319
  • Joined

  • Last visited

Posts posted by MaxStudio

  1. I've also created a 3d tapered object and used the "Add 3d Object to Slab" menu item to attach the object to the slab.  That did attach the 3d object to the slab but, then the horizontal lines of the slab became visible too.  It's almost like the slab became part of the 3d object and inherited it's properties instead of the 3d object becoming part of the slab.

     

    1 hour ago, Boh said:

    I think this is the way to go except make the other chimney parts solid objects (rahter than wall objects) then you can select the whole chimney, right click and "add solids" which will make the whole chimney a "solid addition" and it will remove the unwanted lines. You can still double click on the chimney to enter the addition and edit it later on.

     

    Hi Boh,

    What layer do you put the Solid Chimney Object on?   I was able to get it to work but, I had to do a little extra work.  I will list my process below:

     

    I did what you said and created the Chimney as 1 solid object.  I'm going to call this object "Chimney_Elevation_Object"

     

    I put Chimney_Elevation_Object on the design layer "Slab-1"  (that allows me to show the chimney in elevation but, not on any of the plans because the Slab-1 layer is set to invisible on my plan views)

     

    I still needed the walls of the chimney to show in plan so I created a new class called "Wall-Chimney"  I then went to the First Floor Walls design layer and created the walls for the wider portion of the chimney and put those walls on the Wall-Chimney class.  I then went to the Second Floor Walls design layer and created the walls for the narrower portion of the chimney and also put those walls on the Wall-Chimney class.

     

    Finally, I set the visibility for the Wall-Chimney class to visible on the plans and invisible on the elevations.   See Pictures 3,4 & 5 Below.

     

    Unfortunately, there is a little bit of double work that needs to be done to accomplish this outcome.  In the future, if I change the chimney in plan, I will need to remember to also change the solid Chimney_Elevation_Object.  I will also have to create some more classes for demo and new chimney walls.

     

    Thanks for your help and if anyone else has any further solutions I would love to hear.

    Derek

     

     

    Picture5.png

    Picture4.png

    Picture3.png

    • Like 1
  2. Hello Everyone,

     

    I'm trying to create a chimney that tapers.  (see picture 2)  I've drawn the walls, which represent the wider portion, on the first floor and the walls, that represent the more narrow section, on the second floor.  I need to create the transition piece between (see picture 1).   I want the transition piece to perform much like a slab so that the horizontal lines are invisible when rendering Hidden line.

     

    My questions are:

     

    1.  What is the best way to go about creating this piece?

    2.  I could use a slab but, is there a way to taper a slab?

    3.  I tried creating a polygon, performed and extrude and tapered it.  And while that got me the shape I was looking for it still has the horizontal lines in Hidden Line mode.  Is there a way to hide the horizontal lines?

     

    Thanks

    Derek

     

    Picture1.jpg

    Picture2.jpg

  3. On April 28, 2014 at 11:55 AM, Vladislav Stanev said:

    The encryption (obfuscation) process (run from the Plugin manager or from EncryptVSPluginFilePath call)...

     

    So, Vectorworks would expect an xml file next to your vso/vst/vsm that is being encrypted. This file will define what files must be included...

     

     

     

    I have two questions.  Once I make the xml file where do i save it?  the same plugin folder that the vso file is in?  also  I've never encrypted a plugin using the EncryptVSPluginFilePath is there any documentation which explains this process?  I wonder why there isn't just a button in the Plugin Manager that simply says "ENCRYPT PLUGIN"?

    ... I had to switch my workspace but found a pulldown for Encrypt Scripts but, it doesn't allow me to select a .vso file.  I'm very confused on how to accomplish this encryption.

  4. I created a plugin object using python. The main code was pasted into the script editor via the plugin manager.   I compiled the script and the plugin item works as it should.  Now I would like to lock the script.

    I'm on a mac and recently made the jump from Vectorworks 2008 to 2016.  In the past when creating a vector script I could lock it  by holding down 'command' + 'option' + 'shift' + 'caps lock'  (it was important that all external files had the extension .px)

     

    Now i'm in 2016 and scripting with Python.  I only have 1 other file in addition to "import vs", which is,  "import shapes" when i compile my script (shapes.py).  It finds this file via the scripts options/environment paths.  How do I go about locking or encrypting this plugin object?

     

    also, I do have a __init__.py file included in the folder that contains shapes.py

     

  5. I've eliminated the vs.GetCustomObjectInfo(objname,oh,rh,wh) and just used vs.SetParameterVisibility(handle, 'parametername', FALSE)

    I set the object handle to zero

    vs.SetParameterVisibility(0, 'parametername', FALSE)

     

    I want to use a pulldown to set the visibility to true:

     

    number=vs.Pnumber

    if number == "2":

        vs.SetParameterVisibility(0, 'parametername', True )

     

    but I'm getting the following error:

     

    Error: Invalid callback function parameter type. Parameter index= 0 name=inPlugin

         File "<string>", line 38, in <module>

         File "<string>", line 1, in <module>

     

    below is the actual code:

     

    import vs
    import shapes

    number=vs.Pnumber
    shape01=vs.Pshape01
    shape02=vs.Pshape02
    shape03=vs.Pshape03

    xstart=0

    vs.SetParameterVisibility(0, 'shape01', False )
    vs.SetParameterVisibility(0, 'shape02', False )
    vs.SetParameterVisibility(0, 'shape03', False )

    if number == "2":

        vs.SetParameterVisibility(0, 'shape01', True )
        vs.SetParameterVisibility(0, 'shape02', True )

    if number == "3":

        vs.SetParameterVisibility(0, 'shape01', True )
        vs.SetParameterVisibility(0, 'shape02', True )
        vs.SetParameterVisibility(0, 'shape03', True )

     

     

     

     

  6. I have not assigned a value to objname.  I've created a plugin object and I need to reference and object handle to set the visibilities of the parameter.  how do i acquire or assign these?  

    I thought using the following:

     vs.GetCustomObjectInfo(objname,oh,rh,wh) 

    would have acquired and assigned these for me

  7. I'm trying to set parameter visibility in the object info panel.

     

    In the old vector script I would retrieve the custom object information as follows:

    result:= GetCustomObjectInfo(objname,oh,rh,wh);

    I would then set the visibility of the parameter as follows:

    SetParameterVisibility(oh,'parametername',FALSE);

     

    In python I am trying to accomplish the same thing.

    I've tried the following:

    result = vs.GetCustomObjectInfo(objname,oh,rh,wh)

    and then I attempted to set the visibility as follows:

    vs.SetParameterVisibility(oh, 'parametername', FALSE)

     

    when i run the script I get the following error:

    NameError:  name 'objname' is not defined

     

    Does anyone know how to accomplish this using best practice?

     

    Thanks,

    Derek

     

     

  8. In the past I have run into a problem where the scripting window limits the amount of code I can put in a plugin.  That lead me to start using 'Includes"  after which,  I was no longer limited.  The problem is that some of my codes end up being very long and I do not like scrolling through a ton of code just to find what I'm working on. 

     

    For example, If I have a code that generates 10 types of doors.  In the past I would generate variables for door width/height/wall thickness.  (i would consider those to be global variables)  All of the door types would use those variables.  But not all of the doors would be the same.  Some would be solid, some would be glass and some would be paneled.   To create these individual door types I would have a set of Local Variables for each.   In the past i would create a main include file that sets global attributes and draws global objects.  When the user selected a door type the corresponding include file would load to draw the selected door.  Having the separate "include" file would allow me to work on a simple code to generate each individual door type.  I wouldn't need to work on one large file that includes all 10 doors.  When the code was complete I would lock it within vectorworks so that it would run as a single plugin file.

     

    I'm having a little trouble understanding the best way to accomplish this with python.  I'm not a paid programmer and Im learning as I go.  I'm trying to get a better grip on python as we are moving from Vectorworks 2008 to 2016.  That being said, I find it much easier to comprehend looking at small pieces of code rather than a monster.

  9. I like to deconstruct my larger more complicated scripts into smaller files.  It helps me stay organized.

    I'm trying to get imported functions to use global variables that I have created but, it's not working the way I like and I'm not sure why.

    I have a main script that defines the global variables.  The main script also imports demo.py and calls the function draw.

    The demo.py script is basically an if/else test.  I've imported another file named shapes.py which has functions to draw shapes.

    -If the global variable 'w' is less than 6 call function myrectangle() from shapes.py

    -If the global variable 'w' is greater than 6 call function myoval() from shapes.py

    -if the global variable 'w' is equal to 6 print "Hello World" in a Alert Box.

    When i try to run i get: NameError: global name 'x' is not defined.  I thought that if I had global variables defined in the main script i would be able to use them in the imported functions.  Am I doing something wrong?

    main.py

    import vs
    import demo
    
    w=vs.PLineLength
    h=vs.PBoxWidth
    x = 0
    y = 0
    y = y-h/2
    
    demo.draw()

    demo.py

    import vs
    import shapes
    
    def draw():
    
    	vs.PenSize(2);
    
    	if w < 6:
    
    		shapes.myrectangle()
    
    	elif w > 6:
    
    		shapes.myoval()
    
    	elif w == 6:
    
    		vs.AlrtDialog('Hello world.')

    shapes.py

    import vs
    
    def myrectangle():
    
    	vs.Rect(x,y, x+w,y+h)
    
    def myoval():
    
    	vs.Oval(x,y, x+w,y+h)

     

  10. 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!

  11. 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:

  12. 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()...

  13. 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()?

  14. 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.

  15. 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?

  16. 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

  17. 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.

  18. 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.

×
×
  • Create New...