Jump to content

dane_

Member
  • Posts

    7
  • Joined

  • Last visited

Posts posted by dane_

  1. I have numpy working with VW2024 and VW2021 on a M2 macbook pro. A few things that may help.

    numpy and other complex packages have compiled libraries usually written in C to extend or speed up python.

    These libraries have to be compiled for the hardware and OS they are running on.

     

    There is a correct numpy whl file, and there are all the others. Using the correct one (provided it is not corrupt will work)

    The others will likely not, depending on how bad the incompatibility is with the libraries.

    Using the example posted above https://files.pythonhosted.org/packages/e8/bd/937ffc7345985456c963089418c4c7efdb2ca3af36624c5ea60a07d99bcf/numpy-1.25.0-cp311-cp311-macosx_11_0_arm64.whl'

    This is the wrong file: Breaking down numpy-1.25.0-cp311-cp311-macosx_11_0_arm64.whl

    numpy-1.25.0            installs numpy version 1.25.0

    cp                               C Python

    311                             v3.11

    -macosx_11_0            mac os 11.0

    _arm64.whl                arm64 processors ie M1/M2

     

    The above post says:

    Installed on a mac with M1 processor

    The Python version is: Python3.9 from "/Applications/Vectorworks 2023/Vectorworks 2023.app/Contents/MacOS/Vectorworks"

    The NumPy version is: "1.25.0"

     

    In this case, numpy-1.25.0-cp39-cp39-macosx_11_0_arm64.whl is the correct file.  (*assuming VW2023 was compiled for ARM and not intel, i don't have it to check)

     

    Vectorworks 2021 was compiled for intel processors and runs in Rozetta. The embedded python is also intel and requires an intel _x86_64.whl file

     

    Now, it depends on how you install it. 

    It should be installed into  /Users/YOURUSERNAME/Library/Application\ Support/Vectorworks/2024/Python\ Externals/

    There are a few ways to get it there.

    Using either Marionette.VerifyOrGetLib() or the Marionette installer .vwx file above, and selecting the correct .whl file should work.

     

    Using something like

     pip install -t /Users/dane/Library/Application\ Support/Vectorworks/2024/Python\ Externals numpy-1.25.0-cp39-cp39-macosx_11_0_arm64.whl

    *may* work depending on how you got pip.

    If you upgraded your mac form an intel mac and migrated your data you probably have an x86 build of pip.

    If that is the case and you try to install a arm.whl you will get an error about compatibility with the system.

    pip is running in Rozetta and thinks the Mac is intel

    upgrading pip won't help. You need to install it all again. 

     

    Conversely, if you have VW2021 (intel) and you have an ARM  version of pip you will get a similar mismatch problem.

     

    Using: 

     pip install -t /Users/dane/Library/Application\ Support/Vectorworks/2024/Python\ Externals numpy

    will probably not work because it will install the latest version corresponding to the environment it is running in, and the Python version installed on mac os, not the embeded python in vectorworks

     

    With VW2021 if you use import .vwx file above, it will install to /Applications/Vectorworks 2021/Vectorworks 2021.app/Contents/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy

    This is not a problem, it seems to work ok

     

     

    This may help see what is going on

    import os
    import sys
    import platform
    import vs
    vs.AlertCritical(f"PATH: {os.environ.get('PATH')}\n Python Version {sys.version}"
            +f"\n Platform {platform.machine()}",f"{ sys.path}")
    import numpy as np
    a=np.array([1,2,3,4])
    vs.AlertCritical(f"numpy version {np.__version__}\nnumpy location {np.__file__}",f"result np.array([1,2,3,4]): {a}")

     

  2. To follow up the following works:

    def placeSymbolOnSurfaceAlignedWithUVDelta(u,v, surfaceHandel, symbolName, du,dv):
    	# get the 3d point and vector normal to the surface
    	ptExists, pt, normal = vs.EvaluateNurbsSurfacePointAndNormal(surfaceHandel, u, v)
    	if ptExists:
    		# place the symbol at (0,0,0) then move it. Assumes symbol is defined to be aligned by its insertion point
    		vs.Symbol(symbolName, (0,0), 0)
    		symbolHandel = vs.LNewObj()
    		# create an orientation vector using a point either side of u,v (u-du,v-dv), (u+du,v+dv) where du,dv are small compared to the surface curvature and their relative magnatudes define the orientation in the u,v plane eg u=0,v=0.0001 will result in a vector in the direction of v at the point
    		orentation = tuple(map(sub, vs.EvaluateNurbsSurfacePointAndNormal(surfaceHandel, u+du, v+dv)[1], vs.EvaluateNurbsSurfacePointAndNormal(surfaceHandel, u-du, v-dv)[1])) 
    		# this is a good estiment but it fails because it is not exactly orthogonal to the normal vector. Correct by projecting onto the plane tangent to the surface at u,v
    		uVec = tuple(map(sub,orentation, [vs.DotProduct(orentation,normal)*i for i in normal]))
    		# w-vector is the normal vector
    		wVec = normal
    		# we know the other 2 and they are all orthogonal so v-vector is the cross product of u x w
    		vVec = vs.CrossProduct(uVec,wVec)
    		# offset is the 3d point because the symbol is currently at 0,0,0
    		offsetVec = pt
    		vs.SetEntityMatrixN(symbolHandel, uVec, vVec, wVec, offsetVec)
    		return symbolHandel

     

  3. How do I place a symbol on a NURBS surface normal to the surface.

    Eg. A post on a arched bridge.

     

    I can find the normal vector at the point with vs.EvaluateNurbsSurfacePointAndNormal(surfaceH, u, v)

    I assume I can somehow locate the symbol with vs.SetEntityMatrixN( objectHandle, u , v , w,  offset)

    How do I get the u,v and w vectors? or calculate the angels from the normal vector to use vs.SetEntityMatrix(vs.LNewObj(), *wp)

     

    I can get it to work with:

            vs.SetWorkingPlaneN(*pt, *norm, *uVec)
            wp = vs.GetWorkingPlane()

            vs.Symbol("post", (0,0), 0)
            vs.SetEntityMatrix(vs.LNewObj(), *wp)

     

    The symbol is placed in document space not the working plane but the GetWorkingPlane function returns the angle in degrees needed for SetEntityMatrix

    There must be a better way I am missing...  I am not sure why vs.SetEntityMatrixN needs different inputs to vs.SetWorkingPlaneN

     

    Any pointers appreciated. Thanks

     

×
×
  • Create New...