-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The relative position is inaccurate #60
Comments
Our real application is like the following code. It is really help for this kind of applications if the position issue can be solved.
|
How did you measure the distance between the rectangular holes?
|
Dear David, Once the model is generated in FreeCAD, I export the model as a STEP file; then, I use Solidworks, NX UG, and special measure menu(measure linear) inside FreeCAD's Part workbench, respectively. They all give the same results, ie. 60.1508 and 29.8485. For rectangular holes, I measure the distance between the corresponding sides, which is equal to the distance between the centers. Still don't know the reason. |
I see, thank you. Hmm. Well that is indeed strange. This is a stretch, but can you try a couple of things: ( 1 ) use floating point numbers instead of integers in your script, (2) try the same example but with all coordinates in positive space Let's see if that changes anything. It shouldn't. But who knows.
|
Dear David,
This time, the distance between the first two rect is correct, i.e. 60; however, the distance between the second and the third rect is still inaccurate, and it tells 29.697. I guess that maybe once an extra object is created, the algorithm in the center function change slightly than what we expect. NOT SURE. Any idea how to debug this issue? Thanks. |
OH! it just struck me what may be going on. It is not the center() When you create a workplane, the default center of the workplane is located But when you add holes to a face, the location of a workplane will no I think you'll find that your example works as expected if you first Create a plate with two polygons cut through it#result = cadquery.Workplane("front").center(50.0,100.0).box(width, result = result.faces("<Z").workplane(offset=0.0).center(0.0,0.0).rect(10.0,10.0).rect(-10.0,10.0).rect(20.0,10.0).cutThruAll() with this syntax, you are defining all three rectangles on a workplane On Tue, Oct 13, 2015 at 4:49 AM, huskier notifications@github.com wrote:
|
YES, you are right. With the syntax:
I could get the right answer. But the problem is that what I created is not a simple rect, and it is a complex sketch, so I could not use the syntax like creating three rectangles, except that we have a function called draw2DSketch which do the complex sketch. However, the draw2DSketch function is more harder than polygon function, since polygon stores all the points, and draw2DSketch needs to store wires. I could not deal with so complex issue right now. Could you please give some suggestion how to write function draw2DSketch, or sketch for simple and short? For the draw2DSketch function, I think the coordinates corresponding (the sketch and the targeting workplane) should be considered properly. And I think draw2DSketch, then extrude OR cut into 3D is a typical application. I am looking forward to your help. |
ok cool, so we have explained whats going on, that's a good first step. Jeremy has recently made a change that allows polygon to add edges instead you have a couple of options from here: (1) you can draw all of the 2d stuff before cutting/extruding. that's (2) you can use your previous code, but instead of re-defining a new On Tue, Oct 13, 2015 at 8:43 PM, huskier notifications@github.com wrote:
|
I prefer option 2. Following your option 2, we've the following code, and Only two rectangles are got, not as expected.
For option 1, it is not realistic in my application, because my code is quite complex:
|
ok yeah i see what you mean-- for option 1 to work, you'd need to define a the idea there would be to make your function, and then add it to the cq alternatively, you can make option 2 work if you do some old-fashioned This example is meant to be used from within the CadQuery module of FreeCAD.import cadquery width = 100.0 Create a plate with two polygons cut through itresult = cadquery.Workplane("front").center(50.0,100.0).rect(width, ref_wp = result.faces("<Z").workplane(offset=0.0) result1 = ref_wp.center(0.0,0.0).rect(10.0,10.0).extrude() result4 = result.cut(result1) result4 = result4.cut(result2) result4 = result4.cut(result3) Render the solidshow(result4) On Tue, Oct 13, 2015 at 9:18 PM, huskier notifications@github.com wrote:
|
Personally, I like option 1. But for option 1, there is still some problems. We have to do all the sketch first, and then do 3D operation; otherwise the "center of mass" problem is still there. If we could change the behavior of "workplane", that would be much better. And my previous code just works fine without any change. I will see how to make a workable function like draw2DSketch. Another option is that: |
what would you like the behavior of workplane() to be? the other popular option is to choose the center of the bounding box. This We could consider allowing you to specify the coordinates of the center-- On Tue, Oct 13, 2015 at 9:48 PM, huskier notifications@github.com wrote:
|
"what would you like the behavior of workplane() to be?" Thanks David. I will keep learning the CADQuery code, and I hope I could do more contribution to the project, and make CADQuery more powerful in scripting 3D model. |
Yeah the geometric center has been discussed a couple of time before. Unfortunately, for several reasons it won't work well. In the general case, I wouldn't have an issue adding ability to define a workplace using the We would be happy to accept a pull request for a patch that adds this.
|
Thanks David. I am trying to do something useful. |
Hi @huskier I just wanted to check in to see how you are doing with this. |
@jmwright , following Dave's suggestion(using CenterOfBoundBox instead of CenterOfMass), I could get the correct result now. I am considering submit a pull request to the project. Thanks all of you. |
We're using CADQuery to create a panel with mounting holes, and we positioned the holes with coordinates. However, the relative positions of the holes are inaccurate. Here is an example.
I put the three rectangle holes at points (0,30), (0,-30) and (0, -60) respectively. The distance between the first rect and the second rect holes should be exactly 60, but I've got 60.1508. The distance between the second rect and the third rect holes should be exactly 30, but CADQuery gives 29.8485. I don't know what's wrong with my code. Very weired!
The text was updated successfully, but these errors were encountered: