Curves workbench
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Curves workbench
Thanks @Chris_G I changed the macro to use the values minus 1 and it now appears to be working
I assume the need for the value minus 1 is because the surface is closed or double edges as Ed calls it.
What is the best way to determine if this is the case as opposed to an open surface?
What is the best way to determine if this is the case as opposed to an open surface?
-
- Veteran
- Posts: 3106
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Curves workbench
You could answer this yourself in seconds
sub.Surface.isUClosed() => True
sub.Surface.isVClosed() => False
Got it. I don't know how you develop, but I spend a lot of time looking completions in the Python console. I need to know if methods or properties that I could use already exist.
gets rid of the duplicates. If you have arbitrary surfaces in mind - not just ellipsoids, then it will get much more difficult.
- Select the ellipsoid face
- ctl-shift -p to send to the Python console
- sub.Surface. in the console
- scroll for likely methods
sub.Surface.isUClosed() => True
sub.Surface.isVClosed() => False
Got it. I don't know how you develop, but I spend a lot of time looking completions in the Python console. I need to know if methods or properties that I could use already exist.
Code: Select all
doc = App.ActiveDocument
obj = doc.getObject("IsoCurve")
ob, fa = obj.Face
face = getattr(ob.Shape, fa[0])
surf = face.Surface
umin, umax, vmin, vmax = face.ParameterRange
nu = obj.NumberU - 1
ulist = [i*(umax - umin)/nu + umin for i in range(nu + 1)]
if surf.isUClosed():
ulist = ulist[:-1]
nv = obj.NumberV - 1
vlist = [i*(vmax - vmin)/nv + vmin for i in range(nv + 1)]
boxLength = 2
cmpd = doc.addObject("Part::Compound","CompoundBoxes")
links = []
for u in ulist:
for v in vlist[1:]:
base = surf.value(u, v)
normal = surf.normal(u,v)
#rot = App.Rotation(App.Vector(0,0,1), normal)
tangents = surf.tangent(u, v)
print(f'{tangents[0]} {normal}')
rot = App.Rotation(tangents[0], App.Vector(), normal, 'ZXY')
box = Part.makeBox(boxLength, boxLength, boxLength)
centerpl = App.Placement(-(boxLength/2) * App.Vector(1,1,1), App.Rotation())
box.Placement = App.Placement(base, rot) * centerpl
boxdoc = Part.show(box, 'Box')
links.append(boxdoc)
cmpd.Links = links
doc.recompute()
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Curves workbench
OKay now I want to code another macro that places n objects along the IsoCurve lines. I need a function that I can use to return the position of a point a distance along or fraction of the line length.
I have tried without success
Where edges are taken from the IsoCurves Shape i.e. edges = iso.Shape.Edges
I have tried without success
Code: Select all
edges[i].Curve.value(r)
and
edges[i].valueAt(r)
-
- Veteran
- Posts: 3106
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Curves workbench
Code: Select all
edges[i].Curve.discretize(npts)
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Curves workbench
Thanks, okay now I also need the normals at the corresponding places on the surface.
I see that the surface has a function normal but it seems to take two values ( u and v maybe?)
Anyway to get the normal of the surface at the discretized points?
-
- Veteran
- Posts: 3106
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Curves workbench
Look at the tooltips of the methods of your surface, to find one that returns u, v given the vector location...
How about surf.parameter(vector)?
The opposite direction - get location given u, v?
How about surf.value(u, v)?
The normal at (u,v) - surf.normal(u, v)
The tangent vectors in the u, v directions? - look at the tooltips and figure it out for yourself.
It's all there in the python console.
How about surf.parameter(vector)?
The opposite direction - get location given u, v?
How about surf.value(u, v)?
The normal at (u,v) - surf.normal(u, v)
The tangent vectors in the u, v directions? - look at the tooltips and figure it out for yourself.
It's all there in the python console.
-
- Posts: 4
- Joined: Sat Dec 17, 2022 10:52 am
Re: Curves workbench
Just like to thank Chris (and others) for continued work and dedication with the magnificent curves workbench and answering these questions. Even when the comments start getting a bit heated, Chris it must be hard to take certain levels of criticism when this is something you have worked on for love.
I have only just made an account on here . I have so many information streams it's hard to keep on top of. But I thought I take the time out to wish everyone that's contributed to this superb workbench a happy festive season and show my gratitude to what you have achieved.
I'm returning to the curves wb after taking time to focus on teaching the basics. I have a project that require curves so have stepped back in and am finding things that I didn't know existed or I was blind to.
I do have one question if I may, just to get me on the right path. I am making a version of rhino3D tween curve and need to create a new freehand bspline in a macro without using 'runcommand(gordenprofile,0)' so I can assign it to a variable. I know how to do this with a box in part wb but not sure about curves wb, I think I need to import from curves. That's all I need the rest I can figure out
Thank you once again and hope you all have a nice festive break... Sorry for the long post
MJ
I have only just made an account on here . I have so many information streams it's hard to keep on top of. But I thought I take the time out to wish everyone that's contributed to this superb workbench a happy festive season and show my gratitude to what you have achieved.
I'm returning to the curves wb after taking time to focus on teaching the basics. I have a project that require curves so have stepped back in and am finding things that I didn't know existed or I was blind to.
I do have one question if I may, just to get me on the right path. I am making a version of rhino3D tween curve and need to create a new freehand bspline in a macro without using 'runcommand(gordenprofile,0)' so I can assign it to a variable. I know how to do this with a box in part wb but not sure about curves wb, I think I need to import from curves. That's all I need the rest I can figure out
Thank you once again and hope you all have a nice festive break... Sorry for the long post
MJ
Re: Curves workbench
Hi
welcome mangojellysolutions
many thanks for your instructive video
bonnes fêtes
mario
welcome mangojellysolutions
many thanks for your instructive video
bonnes fêtes
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: Curves workbench
I encountered an issue when using a user created sketch with Sketch on surface.
If the user sketch has no construction line/s, FreeCAD goes unresponsive and process kill is the only option I've found.
Is it possible to check for the lack of construction lines and prevent lockup?
If the user sketch has no construction line/s, FreeCAD goes unresponsive and process kill is the only option I've found.
Is it possible to check for the lack of construction lines and prevent lockup?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Curves workbench
It should be fixed now.
Thanks a lot for your great Youtube tutorials. I think they have become the main source of documentation for people who want to give a try at Curves workbench.mangojellysolutions wrote: ↑Sat Dec 17, 2022 11:27 am Just like to thank Chris (and others) for continued work and dedication with the magnificent curves workbench and answering these questions.
This should put you on the right track :mangojellysolutions wrote: ↑Sat Dec 17, 2022 11:27 am I do have one question if I may, just to get me on the right path. I am making a version of rhino3D tween curve and need to create a new freehand bspline in a macro without using 'runcommand(gordenprofile,0)' so I can assign it to a variable. I know how to do this with a box in part wb but not sure about curves wb, I think I need to import from curves. That's all I need the rest I can figure out
Code: Select all
from freecad.Curves import gordon_profile_FP as GP
sub = []
# If the Spline is snapped to other shapes
# add a link to these shapes. For example :
# sub = [(obj1, ("Edge1",)), (obj2, ("Face1",))]
# the interpolation points
pts = [FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(5, 0, 0), FreeCAD.Vector(10, 0, 0)]
# the type of each point.
# 0 = free point
# 1 = point snapped to a shape of the sub list
# For example, typ = [1, 0, 1]
# means that the first point will snap to the fist shape of the sub list
# and the third point will snap to the second shape
typ = [0, 0, 0]
fp = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Freehand BSpline")
GP.GordonProfileFP(fp, sub, pts, typ)
GP.GordonProfileVP(fp.ViewObject)
fp.recompute()