tutorials for my NURBS macros
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: tutorials for my NURBS macros
Im just guessing here until i can see your file.
For the 'mode undefined' error. I believe this can only happen if you do not have 4 objects selected. Or 3 but ignore that for now.
For the 'curves do not share endpoints' error. Not only must the endpoints be correctly linked at the sketch level, the polys must be selected in the order they form a loop in! Front right back left, not front back left right. In the first case, the second object picked touches the first object. The third touches the second. The fourth touches the third (and the first). In the second example, front doesnt touch back at all. These two cannot be selected in a row.
Why not sort it all out in the macro? Then there would ne no way to say which side is in or out normal wise. It is critical later on.
This is what the specific instructions at step 25 try to enforce.
This is just a guess until i can run a test. You may well be right that the problem is on my side.
For the 'mode undefined' error. I believe this can only happen if you do not have 4 objects selected. Or 3 but ignore that for now.
For the 'curves do not share endpoints' error. Not only must the endpoints be correctly linked at the sketch level, the polys must be selected in the order they form a loop in! Front right back left, not front back left right. In the first case, the second object picked touches the first object. The third touches the second. The fourth touches the third (and the first). In the second example, front doesnt touch back at all. These two cannot be selected in a row.
Why not sort it all out in the macro? Then there would ne no way to say which side is in or out normal wise. It is critical later on.
This is what the specific instructions at step 25 try to enforce.
This is just a guess until i can run a test. You may well be right that the problem is on my side.
Re: tutorials for my NURBS macros
Hi @emills2.
Don't worry about it a bit and take your time. I don't plan to do any more tests today. And it could end up i just need to do something differently. As for the file sure no problem.
Don't worry about it a bit and take your time. I don't plan to do any more tests today. And it could end up i just need to do something differently. As for the file sure no problem.
Re: tutorials for my NURBS macros
Thanks. Now i know what i'm doing after work
Re: tutorials for my NURBS macros
annoying news. your file works fine on my computer the bad part is that makes it very hard for me to debug. please try opening the model attached here on your machine and lets see what it does. If the grid shows up we will be in good shape.
i selected the polys exactly in the order you created them, which is correct (you followed the tutorial perfectly). and bam! in the created object, under the data tab, you can see the exact order they were fed in.
Could you please try it again, but pick the polys from the model tree, not the 3d window?
Here's what can happen if you pick in the window:
if you pick the same one twice in a row, on a different line within the poly, it only registers as one selection object, so you would have 3 objects in the selection, one of which has 2 sub-selections. because the top level of the selection has 3 objects, this would trigger the triangle mode. Since the triangle isn't closed, you then get the 'curves do not share endpoints' error.
In this library, i do a lot of work to completely bypass the topological naming issues in FreeCAD, 90% of the code is handling input, reversing curves, flipping grids as necessary. I have left the absolute bare minimum as rules to follow from the user:
-sketch lines must connect correctly within a sketch
-sketch to sketch connections must be exact
-curves/polys must be picked in the order they actually connect in to form a loop. this is necessary to define inside/outside of surfaces. if you pick counter-clockwise, the surface points towards you.
this last rule is what step 25 in tutorial 0.02 is all about: pick front, right, back, left.
The problem with all of this is that it is tremendously boring, and i was really hoping not to have to talk about it so early in the tutorials. Pretty gumball surfaces are the fun side, topological sketching is the boring price!
I may need to do a premade 4 poly model just to have people focus on picking the polys in the right order. I gambled and decided to focus on the sketches the first time around.
Thank you for putting in all the effort!
@Microelly2 i like gifs too! But sometimes, they just make things more mysterious than before
i selected the polys exactly in the order you created them, which is correct (you followed the tutorial perfectly). and bam! in the created object, under the data tab, you can see the exact order they were fed in.
Could you please try it again, but pick the polys from the model tree, not the 3d window?
Here's what can happen if you pick in the window:
if you pick the same one twice in a row, on a different line within the poly, it only registers as one selection object, so you would have 3 objects in the selection, one of which has 2 sub-selections. because the top level of the selection has 3 objects, this would trigger the triangle mode. Since the triangle isn't closed, you then get the 'curves do not share endpoints' error.
In this library, i do a lot of work to completely bypass the topological naming issues in FreeCAD, 90% of the code is handling input, reversing curves, flipping grids as necessary. I have left the absolute bare minimum as rules to follow from the user:
-sketch lines must connect correctly within a sketch
-sketch to sketch connections must be exact
-curves/polys must be picked in the order they actually connect in to form a loop. this is necessary to define inside/outside of surfaces. if you pick counter-clockwise, the surface points towards you.
this last rule is what step 25 in tutorial 0.02 is all about: pick front, right, back, left.
The problem with all of this is that it is tremendously boring, and i was really hoping not to have to talk about it so early in the tutorials. Pretty gumball surfaces are the fun side, topological sketching is the boring price!
I may need to do a premade 4 poly model just to have people focus on picking the polys in the right order. I gambled and decided to focus on the sketches the first time around.
Thank you for putting in all the effort!
@Microelly2 i like gifs too! But sometimes, they just make things more mysterious than before
- Attachments
-
- ControlGrid44 and CubicSurface44 bare bones - added Grid.FCStd
- (31.61 KiB) Downloaded 34 times
Re: tutorials for my NURBS macros
Code: Select all
curves do not share endpoints
Traceback (most recent call last):
File "NURBSlib_EVM.py", line 1553, in execute
if quad34[0]!=poles3[0] and quad34[0]==poles3[-1]:
<type 'exceptions.TypeError'>: 'int' object has no attribute '__getitem__'
P.S. Anyway i never had such control over surface in FreeCAD yet and i like this new experience. Waiting for the Tutorial_0.03.
Re: tutorials for my NURBS macros
This is my FreeCADtriplus wrote:Do you use the latest FreeCAD 0.17?
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9528 (Git)
Build type: Release
Branch: master
Hash: 4efd3e894a9d3c1954603c60c411d434506d44e7
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
I don't have a linux machine right now, and i don't dual boot (i used to set it up, and always ended up using one OS exclusively per machine). My reference version is 0.17_pre found at https://github.com/FreeCAD/FreeCAD/releases
If i didn't absolutely depend on DeepSOIC's sketch attachment and references, i would insist on 0.16 as the reference. I will add this info in the tutorial. I want anyone to be able to try this without ever having to compile anything. I personally find it a real barrier. I forced myself to compile a few things, thinking that getting it done would give me a sense of victory and accomplishment. It never did. i just ended up feeling i had lost a lot of time and couldn't really tell how many things i'd broken by shoving libraries around .
So far, i have been able to use FreeCAD mechanisms where everything stays exact and falls below the tolerance threshold of every function i use (with no special effort on my part). That is true so far for everything in Part, and whichever portion handles == for vectors (probably Base?)triplus wrote:I haven't check in the code and if you won't be able to confirm this when using latest FreeCAD 0.17. Could this be tolerance related issue? When you compare for equal points do you use tolerance?
But i'm not sure that's even an issue here!
That is what is supposed to happen! the goal of this section of the tutorial is to show how to fix a weak part of the model made in a hurry. The poly endpoints were linked through a sketch reference instead of an attachment, and this breaks when we move one sketch plane but not the other.triplus wrote:Moving the arc sketch (at Z: -200) similar issue:
CODE: SELECT ALL
curves do not share endpoints
Traceback (most recent call last):
File "NURBSlib_EVM.py", line 1553, in execute
if quad34[0]!=poles3[0] and quad34[0]==poles3[-1]:
<type 'exceptions.TypeError'>: 'int' object has no attribute '__getitem__'
The model in the 3D window and the broken object icons in the model tree give just enough information that you don't even need to look at the error messages in the report view. The tutorial then shows how to repair it
Last edited by emills2 on Fri Feb 17, 2017 9:15 pm, edited 1 time in total.
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: tutorials for my NURBS macros
Easier to understandemills2 wrote:triplus wrote:Moving the arc sketch (at Z: -200) similar issue:
CODE: SELECT ALL
curves do not share endpoints
Traceback (most recent call last):
File "NURBSlib_EVM.py", line 1553, in execute
if quad34[0]!=poles3[0] and quad34[0]==poles3[-1]:
<type 'exceptions.TypeError'>: 'int' object has no attribute '__getitem__'
Code: Select all
def orient_a_to_b(polesa,polesb):
else:
print 'curves do not share endpoints'
raise Exception('curves do not share endpoints')
# or
return []
return 0
Re: tutorials for my NURBS macros
triplus wrote: P.S. Anyway i never had such control over surface in FreeCAD yet and i like this new experience. Waiting for the Tutorial_0.03.
i have to do 4 hours of actual code before i'm allowed to do the next tutorial!
You can start building 'quilts' of CubicSurface44s like the pink ones below. edge polys must be shared between grids :use the SAME poly in multiple grids, don't copy paste and reuse. polys must touch at the end, etc. use attachment not sketch link unless you are 100% sure the planes will never move. don't even try to make it too smooth at the seams, just 'sketch in' the major charateristic surfaces of the model. Cubic bezier cannot be smoothed really well at the seam, i have a special non-bezier grid and surface just for that task.
the next set of tutorials will deal with picking point along the edge curves, create grids for subsections, blend two grids that share an edge...like so
Re: tutorials for my NURBS macros
I take your word for it, i only know as much about programming as i absolutely need to get the task at hand done. my error reporting techniques are not very consistent. most of the time i print intermediate steps to the console until it works, then i comment out the prints.microelly2 wrote:Easier to understandemills2 wrote:triplus wrote:Moving the arc sketch (at Z: -200) similar issue:
CODE: SELECT ALL
curves do not share endpoints
Traceback (most recent call last):
File "NURBSlib_EVM.py", line 1553, in execute
if quad34[0]!=poles3[0] and quad34[0]==poles3[-1]:
<type 'exceptions.TypeError'>: 'int' object has no attribute '__getitem__'
instead ofCode: Select all
def orient_a_to_b(polesa,polesb): else: print 'curves do not share endpoints' raise Exception('curves do not share endpoints') # or return []
return 0
There are multiple things going on here that are not clear yet to me.
are we talking about:
-the polygon loop being picked in the wrong order?
-failures in the macro itself?
-failures in the functions called by the macro?
i have no way of testing beyond
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9528 (Git)
Build type: Release
Branch: master
Hash: 4efd3e894a9d3c1954603c60c411d434506d44e7
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
I will look into raising exceptions. it does sound better.
Re: tutorials for my NURBS macros
No that ain't going to cut it. I'll wait.emills2 wrote:You can start building 'quilts' of CubicSurface44s like the pink ones below.
Yes this is similar to the version i used. If you will try the latest one (Version: 0.17.10101):Version: 0.17.9528 (Git)
https://github.com/FreeCAD/FreeCAD/releases
You will likely observe the same issue as mentioned earlier. Note that i didn't check the code and i don't know if anything changed in FreeCAD. If it's tolerance related something like this should fix it (in pseudocode):
Code: Select all
if abs(p1 - p2) < 1e-07:
points equal
else:
points not equal