[Closed] help with nurbs
Hello,
I have a problem with a script that I made that populates a NurbsCVsurface with points the position of which is extracted from a given u,v coord.
Here is the code:
fn grabNURBSSurface myNurbsNode =
(
undo "grabNURBSSurface" on
(
if myNurbsNode != undefined then
(
if classof myNurbsNode == NURBSSurf do
(
nobject = copy myNurbsNode
ns = getnurbsset nobject #relational -- get the nurbs set for it
num = ns.numobjects
for i=1 to num do
(
isGeometry = false
if classof ns[i] == NURBSCVSurface then isGeometry = true
--if classOf ns[i] == NURBSPointSurface then isGeometry = true
if isGeometry then
(
makeIndependent nobject ns[i].nurbsid
)
)
nset = getnurbsset nobject
nset[1] -- return nurbs geometry
)
)else messagebox "you haven't selected anything";
)
)
surf = grabNURBSSurface $
step = 1/25 as float
for i=0.0 to 1.0 by (step*2) do
(
for j=0.0 to 1.0 by (step*2) do
(
thepos1 = evalpos surf i j
thepos1 = thepos1*surf.transform
point pos:thepos1 wirecolor:[0, 0, 0]
)
)
But, the points keep falling outside my nurbs surface and always near [0, 0, 0].
Anyone knows why?
Uploaded with ImageShack.us
This should work:
fn grabNURBSSurface myNurbsNode =
(
undo "grabNURBSSurface" on
(
if myNurbsNode != undefined then
(
if classof myNurbsNode == NURBSSurf do
(
nobject = copy myNurbsNode
ns = getnurbsset nobject #relational -- get the nurbs set for it
num = ns.numobjects
for i=1 to num do
(
isGeometry = false
if classof ns[i] == NURBSCVSurface then isGeometry = true
--if classOf ns[i] == NURBSPointSurface then isGeometry = true
if isGeometry then
(
makeIndependent nobject ns[i].nurbsid
)
)
nset = getnurbsset nobject
nset[1] -- return nurbs geometry
)
)else messagebox "you haven't selected anything";
)
)
surf = grabNURBSSurface $
tranSurf = $.transform
step = 1/25 as float
for i=0.0 to 1.0 by (step*2) do
(
for j=0.0 to 1.0 by (step*2) do
(
thepos1 = evalpos surf i j
thepos1 = thepos1*tranSurf
point pos:thepos1 wirecolor:[0, 0, 0]
)
)
Yeap, it works ! Thank you SamSed!
I have one more question concerning nurbs, maybe you know it.
I create a PointSurface instead of CVSurface and use that function that I posted earlier to grab the correct nurbs geometry from the nurbset. But then, if I ask for “classof surf”, instead of NURBSPointSurface in gives me again a NURBSCVSurface. Why is that ?
Maybe I have to replace the makeIndependent function with something else ?
According to the manual “This function takes a dependent sub-object (fillet, offset, blend, etc.) and turns it into a CV variant of itself such that it is independent (no longer dependent on a parent).”