Jump to content

twk

Member
  • Posts

    715
  • Joined

  • Last visited

Posts posted by twk

  1. Does anyone know which function calls to use for setting record fields to be controlled by the data manager field mapping.

     

    Have just setup a data mapping for a particular record to WinDoor objects, and they seem to work -- manually, however I have the records already attached to some odd 200 objects.

     

     

     

    image.thumb.png.cad06c928a22770e357dca1b0cb43f21.png

     

     

    image.png.361568acc4b45683b573ed93208c9ad6.png

     

    Have tried vs.SetParamStyleType, put that seems to be only for plugin objects, not records.


    Any help, or pointers in the right direction would be greatly appreciated.

     

    Cheers,

    Tui

     

  2. On a side note, heres a snippet that lists out all installed modules for your python environment (adapted for vectorworks, by adding vs.CreateText(), to be run on design/sheet layer). 

     

    def list_modules():
        import pkg_resources
        installed_packages = {d.project_name: d.version for d in pkg_resources.working_set}
        # print(pkg_resources.working_set)
        text_data = []
        for k, v in installed_packages.items():
            # print(f"{k} : {v}")
            text_data.append(f"{k} : {v}")
    
        import vs
        vs.CreateText(f"{vs.Chr(13)}".join(text_data))

     

    • Like 3
  3. GetLName returns the name of the referenced layer, eg.

    # the current design layer name = 'Layer 1'
    # to get a handle to the active layer, you'd use vs.ActLayer()
    
    layername = vs.GetLName(vs.ActLayer())
    vs.AlrtDialog(layername)
    # should display 'Layer 1'

     

    I think what you're after is vs.GetLayer(HNDL).

    https://developer.vectorworks.net/index.php/VS:GetLayer

     

    and then vs.GetLName

    eg

    h = vs.FSActLayer()
    layer_name = vs.GetLName(vs.GetLayer(h))
    # vs.GetLayer(h) returns a HANDLE to the layer the object 'h' belongs to

     

    • Like 1
  4. The error is saying your indentations are inconsistent/incorrect.

    Indentations are important for python. You must either use 4-spaces, or a single TAB, you can't use both in one script.

    try this:

    for a in range (4):
    #	vs.CreateWS('WS_TEST'+a+',2,2')
    	worksheet = vs.GetObject(vs.Concat('WS_TEST',a))
    	if worksheet not in [None, 0]:
    		vs.CreateWS((vs.Concat('WS_TEST',a)),2,2)
    	vs.SetWSColumnWidth((vs.Concat('WS_TEST',a)),1,1,50)
    	vs.SetWSColumnWidth((vs.Concat('WS_TEST',a)),1,1,20)
    	vs.SetWSRowHeight((vs.Concat('WS_TEST',a)),1,1,20,0,0)
    	vs.SetWSRowHeight((vs.Concat('WS_TEST',a)),2,2,20,0,0)
    	vs.SetWSCellFormulaN((vs.Concat('WS_TEST',a)),1,1,1,1,a)

     

    • Like 2
  5. I'm not sure the function itself shortens the variable 'p'. It overrides it completely with whatever the GetPolyPt or any other function spits out. Which in the case of the GetPolyPt is a 2-dim tuple.

     

    So in the case of the vs.Vec2Ang() function, that particular function 'requires' a 3-dim tuple, when you are passing values from GetPolyPt into the Vec2Ang function you'd have to unpack the values you get from GetPolyPt and add a 3rd value.

     

    p = vs.GetPolyPt(handle_to_poly, 1)
    ang = vs.Vec2Ang((p[0], p[1], 0)) # the third value 0 is added by you

     

     

    I think we are coming to the same conclusion, I'm just a bit thrown off by your original post stating "If you passed some z values before in the third slot, you'll loose them".

    From my knowledge whatever 'p' was before you set it is overwritten with this new value and type.

     

    I also just saw your commenting on the DevWiki which explains things very clearly.

     

  6. I'm not following.

    Maybe this is a python thing, but the value of your variable 'p' gets overwritten once you set it to vs.GetPolyPt(vs.FSActLayer(), 1).

    The GetPolyPt function always returns a tuple of 2 values. So whatever 'p' was before will become whatever GetPolyPt gives it.

     

    eg.

    p = "Hello there"
    print(p)
    # "Hello there"
    p = (0,1,2)
    print(p)
    # "(0,1,2)"

     

    variables in python are dynamically typed.

×
×
  • Create New...