Trying to use pymel to get nurbSurface information, getting an error related to SafeApiPtr

106 views
Skip to first unread message

Ryan J Roberts

unread,
May 7, 2015, 3:30:55 PM5/7/15
to python_in...@googlegroups.com
So I'm trying to use pymel to get information about a point on a nurbsSurface. First I make a PyNode

nurbsSurface = pm.PyNode('nurbsPlaneShape1')

which allows me at to use all the methods in the pymel nurbsSurface nodetype.

I'm able to get some information with no problem, but I'm trying to use the method nurbsSurface.closestPoint(), and I'm giving it a list of 3 numbers.

closestPoint = surf.closestPoint( [0.1, 0.3, 0.2] )

and it's giving me this error:

unbound method get() must be called with SafeApiPtr instance as first argument (got list instance instead)

Does anyone have any experience with SafeApiPtr?  I'm having problems finding out what it is and how to use it.

Any help would be greatly appreciated :-)

Justin Israel

unread,
May 7, 2015, 3:45:50 PM5/7/15
to python_in...@googlegroups.com

Can you show a complete and concise example of the problem? It seems like you are calling closestPoint() on the Nurbsurface class and not an instance. Either that or a bug. I wouldn't think you should need to worry about the SafeApiPtr stuff as that is probably internal and it is referring to a problem of not being called on a valid instance.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5fb010d7-5ef3-45f8-9b78-6772ad1a2fdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ryan J Roberts

unread,
May 7, 2015, 5:30:44 PM5/7/15
to python_in...@googlegroups.com
Hi Justin,

That pretty much is the complete example using pymel.  I ran into this issue pretty quickly.  In the pymel docs, under nodetypes, you can find the nurbsSurface node information and all its methods. Some methods seem to work pretty easy, like the "getPoints()" method, but "closestPoint()" seems to have a requirement I don't fully understand.  The pymel nodetypes seem to have a lot of connections to the api, and I think SafeApiPtr makes a different type of variable than the normal python variable.


On Thursday, May 7, 2015 at 12:45:50 PM UTC-7, Justin Israel wrote:

Can you show a complete and concise example of the problem? It seems like you are calling closestPoint() on the Nurbsurface class and not an instance. Either that or a bug. I wouldn't think you should need to worry about the SafeApiPtr stuff as that is probably internal and it is referring to a problem of not being called on a valid instance.


On Fri, 8 May 2015 7:30 AM Ryan J Roberts <ryan.j....@fuhu.com> wrote:
So I'm trying to use pymel to get information about a point on a nurbsSurface. First I make a PyNode

nurbsSurface = pm.PyNode('nurbsPlaneShape1')

which allows me at to use all the methods in the pymel nurbsSurface nodetype.

I'm able to get some information with no problem, but I'm trying to use the method nurbsSurface.closestPoint(), and I'm giving it a list of 3 numbers.

closestPoint = surf.closestPoint( [0.1, 0.3, 0.2] )

and it's giving me this error:

unbound method get() must be called with SafeApiPtr instance as first argument (got list instance instead)

Does anyone have any experience with SafeApiPtr?  I'm having problems finding out what it is and how to use it.

Any help would be greatly appreciated :-)

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Juan Diego Lugo

unread,
Dec 13, 2016, 6:03:19 PM12/13/16
to Python Programming for Autodesk Maya, ryan.j....@fuhu.com
Bumping post in 2016 :)

Just stumbled upon this thread after seeing this is still an issue. I'm wondering if anyone else is experiencing it.

I am using an instance of NurbsSurface and not calling the class itself, like so:

import pymel.core as pm
import maya.cmds as cmds

plane
= cmds.nurbsPlane(ch=False)[0]
pos
= pm.dt.Point(0,0,0)
shape
= pm.PyNode(plane)
shape
.closestPoint(pos, space='world')

Thus triggering:
# Error: TypeError: file /usr/autodesk/maya2016/lib/python2.7/site-packages/pymel/internal/factories.py line 1782: unbound method get() must be called with SafeApiPtr instance as first argument (got list instance instead) # 

Paul Molodowitch

unread,
Dec 16, 2016, 3:16:57 PM12/16/16
to Python Programming for Autodesk Maya, ryan.j....@fuhu.com
This should be fixed by the lastest commit on github:

https://github.com/LumaPictures/pymel/commit/b9147cafb4a2ee5a90e86c650f0d54aa8b8ce365

Thanks for the clear replication code!

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/73681b39-44ad-4b3e-947a-b3b694d03c4f%40googlegroups.com.

Juan Diego Lugo

unread,
Dec 16, 2016, 4:00:32 PM12/16/16
to Python Programming for Autodesk Maya, ryan.j....@fuhu.com
Many thanks!!
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages