I want to get boolean difference result of closed curve substracted by Brep. The direct way is:
- create surface brep from closed curve
- get the face of brep intersected with curve
- using CreateBooleanDifference with surface and face
But CreateBooleanDifference only support surfaces that one contain another.
So, the alternative way is:
- create surface brep from closed curve, then create extrusion from surface.
- get the face of brep intersected with curve, then create extrusion from face.
- using CreateBooleanDifference with two extrusion
- get bottom face and face’s edges.
But CreateBooleanDifference is strange.
First example, this result is union of two
Second example, this result is that Brep is substracted by polyline, not polyline substracted by brep.
Furthemore, keep extrusions created by code, and then do Boolean difference via builtin command BooleanDifference, the result is right. It seems that extrusions created by code are ok, and there is something wrong with api CreateBooleanDifference?
Below is test model and code, Thanks!
SU-polyline.3dm (39.2 KB)
SUTestCommand.cs (4.1 KB)
@dale, Would you please have a look at this problem?
Does this sample help?
@dale，thanks for your reply, it works in one scenario and failed in another one.
Replace my code creating Brep from curve with code in sample, the result are different: one is correct, and another is wrong, it is shown in below picture.
updated code is below:
SUTestCommand.cs (7.0 KB)
@dale , the behaviour of CreateBooleanDifference is odd, Do you have any idea about this?
My apologies, but I don’t understand what your command is trying to do. Perhaps you can provide a description of what you are trying to do, and why? A step-by-step of what you are trying to do would be helpful.
Also, can simply your 3dm file and only provide the geometry you need to test the command? It’s not clear to me what to select and what not to select.
What try to do: I want to get boolean difference result of closed curve substracted by Brep.
Take below image for example, there are two groups of curve and Brep, what i want are closed curves with red color.
Steps to achieve it
2.1. create surface brep from closed curve, then create extrusion from surface.
2.2. get the face of brep intersected with curve, then create extrusion from face.
2.3. using CreateBooleanDifference with two extrusion
2.4. get bottom face and face’s edges. the step has not been implemented in code
simplied 3dm file sample code are below. In updated code, the Objects are selected by id, no need to select by mouse.
SU-polyline.3dm (44.1 KB)
SUTestCommand.cs (5.0 KB)
Have a look at the attached, and let me know if you have any questions.
SUTestCommand.cs (5.1 KB)
Hi @dale , Thanks for your reply, it solves this problem.
I still have some questions
why my code cause wrong result. the difference of code is the way to create breps:
1.1 From curve to Brep
mine: curve → Brep.CreatePlanarBreps(curve) → first BrepFace → BrepFace.CreateExtrusion
yours: curve → Surface.CreateExtrusion(curve) → surfaceBrep.Faces.SplitKinkyFaces → surfaceBrep.CapPlanarHoles
1.2 From BrepFace to Brep
mine: BrepFace → BrepFace.CreateExtrusion
yours: BrepFace → edge curve → Surface.CreateExtrusion(curve) → surfaceBrep.Faces.SplitKinkyFaces → surfaceBrep.CapPlanarHoles
Would you please share some resource about Brep, i can’t understand the meaning of Loop, Trim, Edge.
You may find this useful.
@dale Thanks for sharing.
Below link is also useful