Silk: a NURBS workbench

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Silk: a NURBS workbench

Post by sliptonic »

@Russ4262 has been doing some great work on the Path workbench to improve the 3D surfacing capabilities. One thing we need are some test models.

Would someone here be willing to build some shapes that are suitable to include in cnctorture?

Ideal shapes would be relatively simple solids incorporating 1 or more nurbs surfaces. More shapes are better than one shape with lots of surfaces but shapes with increasing complexity are great.

I won't pollute this thread any more than necessary so please reply to the CNCTorture thread linked above.

Thank you.
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Silk: a NURBS workbench

Post by keithsloan52 »

A while back I became aware of OpenNURBS and started a workbench https://github.com/KeithSloan/FreeCAD_ImportNurbs But the library at the time was just C++ so it was hard going, so never really got anywhere. Recently @zohozer pointed out that there was now python bindings see this thread https://forum.freecadweb.org/viewtopic.php?f=8&t=11970 @Chris_G put together some code. I started a new workbench https://github.com/KeithSloan/ImportNURBS and added Chris's code.

But if you look at the screen shot
ImportNURBS.png
ImportNURBS.png (490.35 KiB) Viewed 2337 times
What are BRep_Faces which are BSpline_Surfaces end up as FreeCAD Faces but with no editable Properties.
To my mind we/I should be converting to something that one of the various workbench's that deal with NURBS, Bezier, can then edit.

Question: Does Silk just deal with NURB Surfaces? or can it do other types of surface, like Bezier etc?
What about the other Surface related workbenches.

i.e. Which workbench should I be taking a fork of and trying to add an importer using OpenNURBS?
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Silk: a NURBS workbench

Post by microelly2 »

keithsloan52 wrote: Wed Mar 25, 2020 6:18 am Question: Does Silk just deal with NURB Surfaces? or can it do other types of surface, like Bezier etc?
What about the other Surface related workbenches.

i.e. Which workbench should I be taking a fork of and trying to add an importer using OpenNURBS?
At the end you always have BSpline surfaces and BSplines curves as border for patches.

For both datatypes there are classes in FreeCAD.Part: BSplineSurface and BSpline Curve

These object are full featured Nurbs and they are full parametric.

Beziers are a special case of BSplines, So IMO there is no need to have Beziers as background data model.
You can write your importer in a separate workbench or modul, so we can in stall it and use it in other workbenches.
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Silk: a NURBS workbench

Post by keithsloan52 »

microelly2 wrote: Mon Mar 30, 2020 6:26 am
keithsloan52 wrote: Wed Mar 25, 2020 6:18 am Question: Does Silk just deal with NURB Surfaces? or can it do other types of surface, like Bezier etc?
What about the other Surface related workbenches.

i.e. Which workbench should I be taking a fork of and trying to add an importer using OpenNURBS?
At the end you always have BSpline surfaces and BSplines curves as border for patches.

For both datatypes there are classes in FreeCAD.Part: BSplineSurface and BSpline Curve

These object are full featured Nurbs and they are full parametric.

Beziers are a special case of BSplines, So IMO there is no need to have Beziers as background data model.
You can write your importer in a separate workbench or modul, so we can in stall it and use it in other workbenches.
Well Chris_G has written the code for a NurbsSurface and I adjusted his attempt for a NurbsCurve, When I import a file with these components they display, but if I select them I don't see any relevant properties in FreeCAD's property window, so not convinced we are doing things correctly.

github repro is at https://github.com/KeithSloan/ImportNURBS

Sample 3DM files are available at https://www.rhino3d.com/download/openn ... bs6samples

Test file for surfaces is V6 - mysurfaces.3dm

Test Curve is V6 - mycurves.3dm
emills2
Posts: 868
Joined: Tue Apr 28, 2015 11:23 pm

Re: Silk: a NURBS workbench

Post by emills2 »

keithsloan52 wrote: Mon Mar 30, 2020 7:24 am
microelly2 wrote: Mon Mar 30, 2020 6:26 am
keithsloan52 wrote: Wed Mar 25, 2020 6:18 am Question: Does Silk just deal with NURB Surfaces? or can it do other types of surface, like Bezier etc?
What about the other Surface related workbenches.

i.e. Which workbench should I be taking a fork of and trying to add an importer using OpenNURBS?
At the end you always have BSpline surfaces and BSplines curves as border for patches.

For both datatypes there are classes in FreeCAD.Part: BSplineSurface and BSpline Curve

These object are full featured Nurbs and they are full parametric.

Beziers are a special case of BSplines, So IMO there is no need to have Beziers as background data model.
You can write your importer in a separate workbench or modul, so we can in stall it and use it in other workbenches.
Well Chris_G has written the code for a NurbsSurface and I adjusted his attempt for a NurbsCurve, When I import a file with these components they display, but if I select them I don't see any relevant properties in FreeCAD's property window, so not convinced we are doing things correctly.

github repro is at https://github.com/KeithSloan/ImportNURBS

Sample 3DM files are available at https://www.rhino3d.com/download/openn ... bs6samples

Test file for surfaces is V6 - mysurfaces.3dm

Test Curve is V6 - mycurves.3dm
basically all surfaces in freecad have full nurbs functionality. it's the core. what ChrisG, Microelly, and myself have done is based off of the existing objects. we just go about it different ways. if you have an external nurbs object you want to import, you need to figure out how to read its knot vectors and pole/weight tables. then feed them into the freecad objects. it gets trickier with trimmed surfaces, but it's all there.

the reason we have all these different tools is because the core nurbs object doesn't tell you how to go about creating the knot vectors, poles, etc.

but if you're importing, it's just a translation exercise (at a first glance, i'm sure there'll be some puzzles)

edit: as far as editing the imported objects....you can already use the python console to read the existing pole tables, edit them and create new modified objects....but that feels more like trying to model with chewing gum than it feels like modeling with clay.

if you don't have access to the underlying curves and the tools that were used to generate the surfaces, you end up with a challenge similar to, for example, editing a step object without the modeling history.
emills2
Posts: 868
Joined: Tue Apr 28, 2015 11:23 pm

Re: Silk: a NURBS workbench

Post by emills2 »

sliptonic wrote: Tue Mar 17, 2020 2:34 pm @Russ4262 has been doing some great work on the Path workbench to improve the 3D surfacing capabilities. One thing we need are some test models.

Would someone here be willing to build some shapes that are suitable to include in cnctorture?

Ideal shapes would be relatively simple solids incorporating 1 or more nurbs surfaces. More shapes are better than one shape with lots of surfaces but shapes with increasing complexity are great.

I won't pollute this thread any more than necessary so please reply to the CNCTorture thread linked above.

Thank you.
i'll try to make something, but i can't say when. unfortunately very little time for FreeCAD these days.
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Silk: a NURBS workbench

Post by keithsloan52 »

emills2 wrote: Mon Mar 30, 2020 7:34 am
Well I just tried installing @Microelly nurbs workbench via the AddonManager to see if I could select and change one the imported curves and edit it, but it seems the workbench has not been updated for Python3 :-(
yes, it runs only with py2,
I started the work with python3 with the pyflow node editor project
emills2
Posts: 868
Joined: Tue Apr 28, 2015 11:23 pm

Re: Silk: a NURBS workbench

Post by emills2 »

Andyk has contributed some icons and fairly comprehensive tooltips! thanks Andy, it's really neat to see a full toolbar.

I also just pushed a fix that corrects an error for automatic G2 blend surfaces where half of the weights were assigned incorrectly. no impact on models that do not directly edit weights or use arcs.
Silk_model_163.1_fixed_arc_weights_00.png
Silk_model_163.1_fixed_arc_weights_00.png (393.74 KiB) Viewed 1352 times
pic below of model using arc edges in both base surfaces (arc on left, arc on right). now blending correctly --- note the clean zebra across the segmentation lines --- this is a stress test, so the fold is not pretty, but the blend is doing what is asked of it.
Silk_model_163.1_fixed_arc_weights_00.png
Silk_model_163.1_fixed_arc_weights_00.png (393.74 KiB) Viewed 1352 times
Attachments
Silk_model_163.1_fixed_arc_weights.FCStd
(95.84 KiB) Downloaded 23 times
emills2
Posts: 868
Joined: Tue Apr 28, 2015 11:23 pm

Re: Silk: a NURBS workbench

Post by emills2 »

I was wondering who user gnosys is, who has been making Silk models for themselves and to help others.

Turns out they are on Reddit...which is where i have been hiding away from FreeCAD the past two years LOL.

anyways, i replied to their old post https://old.reddit.com/r/FreeCAD/commen ... workbench/

and i also want to share that reply here. There's a bit of tough love for FreeCAD in there, no offense intended, but i needed to frame my point. feel free to tell me how wrong i am :)
Hi gnosys, nice work.

it's pretty funny to realize people have been posting Silk stuff on reddit, since i haven't done much development with Silk lately, and i spend all my free time on reddit (lurker).

out of a mix of pride and self doubt, i googled "FreeCAD Silk" since i was getting no traction on the forum. lo and behold, i find not one, but two users on reddit that have figured basic usage AND applied it to their own work (as opposed to doing the tutorial, then not much else).

Are you on the FreeCAD forum as well under a different name?

what you did here is exactly why i published my workbench even though it is unfinished. it can patch an existing problem or a broken step file. it's not much, but it's a very real thing.

I really wish you would post to my "workbench thread" with models, pics, descriptions, etc. (viewtopic.php?t=23243). it would help others see real usage, and motivate me to work on this project.
my biggest gripe is there is absolutely no system at all for organizing the objects, so today i feel like i'm going to start reading the source and learning how to script folders, see if i can submit a patch.
I've been waiting years to see if Part Design or realthunder's branch would ever produce a reasonable parametric object tree (like Pro/E, Solidworks, catia, Inventor, NX, fusion....etc...the REAL parametric CADs*) so far i don't like much of what i see. but things may have changed lately.

the key is that although a sketches should nest under polys, polys should nest under grids, grids should nest under surfaces....FreeCAD has been obsessed since day 1 to 'fully absorb features' and make them unavailable elsewhere. i reuse data all the time. Part Design used to do this thing where you couldn't reuse a sketch in an extrusion for another extrusion. ridiculous stuff. realthunder's links and shape binders help, but i don't want to create an intermediary object, and then trace that intermediary object. sometimes i trace part of a layout sketch into a node sketch, but those are two legitimate separate entities, not just tracing for the sake of tracing. these are all artificial obstacles, shown by the fact that Silk can reuse the same node sketch in as many polys as i want, with no special coding.

personally, i just make folders and FORCE FreeCAD to present me something that looks like a history-based parametric model tree.

BELOW NOT IMPLEMENTED

my next goal for this is to:

-keep all object in order of creation (basic history)

-ability to bump objects up or down the tree if it doesn't violate dependency order (smart history)

-nest a link to input inside objects (open surface see grid inside, open poly see sketch inside)[EDIT: basically opening an object in the tree should show you a visualization of its properties>data tab], and have an option to hide the inputs from the main tree (no limit on multiple linking)

-create an 'elements folder' at the root of the doc, and automatically throw links to all points in a points subfolder, all grids in a grids subfolder, etc. this way you can browse through element types.


a key point is these need to be direct links. say i have a sketch, shown in the tree, used in 2 polys, shown in the sketches subfolder. double clicking that sketch should go to edit mode without moving my position in the tree.

what i'm talkng about is pointers to the same object that don't make me lose my position in the tree.

i use realthunder links to make copies and move them around, and that is where the link workflow makes sense. they are also the correct thing for component reuse and assemblies.Sketcher Sketches can be partially traced from each other directly. subshape binder exists only to circumvent greedy feature absorption.

more details:

-from any pointer (nest, main tree, subfolder), i want to right click> show/hide in tree

-an option to autohide in tree would clean up the tree as you use stuff

-you want to reuse something that already hidden? find it either from inside the consuming feature or the type
subfolder, and click it. no link creation, no shape binders.

a mechanism to highlight other pointers of an object would be nice.

anyways, i'd love to hear your ideas too if you have time to discuss them. I would much prefer to do so on the freecad forum though...try to keep the source of info central.

Cheers

* through terrible luck, i am currently using the program that i believe the creators of FreeCAD wanted to emulate originally (they'll never admit to it for fear of being sued), and now i understand why things in FreeCAD are the way they are. I don't like that program. I've learned it and i can make it do anything i want, but i don't like it. I would rather draw in the dirt with a stick then choose to use it. it's basically a survivor from the 1980s that refused to clone Pro/E or reimplement the core features. CATIA, Solidworks, NX, Inventor, Fusion, are all Pro/E clones at their cores. for a very good reason: it is the superior system. although Part Design was always an attempt to clone the Pro/E core system, it did so with strange limitations, and a strange model tree. those limitations and that model tree are the remains of that obsolete 1980s system. nothing wrong with having it, but painful to not have options

Part Design Next was a long war with many great battles to make Part Design somewhat usable, which improved it immensely. weirdness still lurks in the corners tho....preventing you from directly linking info.

Silk is based entirely on the Part level, which has no limitations....but that leaves the weird model tree. i'm obviously free to write my own model tree, but like i said, i wanted to see how part Design and Realthunder's stuff shakes out.
I guess my reason to repost this here is to ask: have you found a way to nest/organize/links your workbench objects in a neat way? what do do you think about the kind of features for a model tree i described above? is it already possible? is there already better? I criticize FreeCAD, but i'm open to new systems....that don't involve telling me to trace entire sketches over and over (partial tracing is fine, since the partial selection is itself new data).
emills2
Posts: 868
Joined: Tue Apr 28, 2015 11:23 pm

Re: Silk: a NURBS workbench

Post by emills2 »

another point which may be interesting.

in some of the Standard parametric CADs (to keep it generic), you can find a "body" folder before the history tree begins. in this folder, you will find every solid created along the way to making the model...the names of these solids will look suspiciously like the names of the subshapes sof a complex model from the Part workbench.

like fillet3>fillet2>fillet>extruded-cut>revolve>sketch.

so it would appear that the basic Part model tree is an underlying universal structure. It's not so much that it's 'weird' to work with, but that all other modern CADs basically hide this layer from you unless you go digging (which they also allow you to do).

Which brings up another question for me. Should i even try to organize the FreeCAD model tree? would i be better off writing a new module that create the model tree i want? That doesn't sound right, considering what i see in Part Design is so close (yet so far).

I need a concept of visibility for items in the tree that is separate from the visibility of the shape of the shape the item points to.

I need to create multiple entries in the FreeCAD tree that point to the same FreeCAD document object (not links, THE same object).

i need an concept of an index position for an item in the histroy portion of the tree (with a separate min and max allowed index position as well to represent dependency)

....

is this buildable from what already exists in the tree viewer, or should i add a new panel that reads and manipulates from the exisitng tree viewer?
Last edited by emills2 on Thu Apr 06, 2023 12:43 am, edited 1 time in total.
Post Reply