Create Face object using Edges intersections

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
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!
jtm2020hyo
Posts: 565
Joined: Wed Aug 12, 2020 1:24 am

Create Face object using Edges intersections

Postby jtm2020hyo » Thu May 13, 2021 10:17 pm

Image

I did not find any method to create such shape, maybe some experimented user could help?

Image
Attachments
intersection.FCStd
(10.5 KiB) Downloaded 13 times
drmacro
Posts: 3389
Joined: Sun Mar 02, 2014 4:35 pm

Re: Create Face object using Edges intersections

Postby drmacro » Thu May 13, 2021 10:43 pm

faces require a closed profile, no intersections.

you could create points at those intersections and use Part workbench Builder tool selecting the points.

https://wiki.freecadweb.org/Part_Builder

or use a sketch, use the trim tool to trim the lines. this will automatically create coincidents on the ends of the lines. the close the sketch and use the face tool in Part or Draft.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."

My beginners, written treatise: Learning FreeCAD
jtm2020hyo
Posts: 565
Joined: Wed Aug 12, 2020 1:24 am

Re: Create Face object using Edges intersections

Postby jtm2020hyo » Fri May 14, 2021 12:27 am

maybe is there any method to split Draft WB Lines or Sketches WB Lines, I mean break the line(s) in the intersections?
chrisb
Posts: 35270
Joined: Tue Mar 17, 2015 9:14 am

Re: Create Face object using Edges intersections

Postby chrisb » Fri May 14, 2021 12:38 am

jtm2020hyo wrote: Fri May 14, 2021 12:27 am maybe is there any method to split Draft WB Lines or Sketches WB Lines, I mean break the line(s) in the intersections?
What do you mean by "break the lines"? drmacro has already described what to do to get a face from this.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
mario52
Posts: 3521
Joined: Wed May 16, 2012 2:13 pm

Re: Create Face object using Edges intersections

Postby mario52 » Fri May 14, 2021 11:22 am

hi
jtm2020hyo wrote: Fri May 14, 2021 12:27 am maybe is there any method to split Draft WB Lines or Sketches WB Lines, I mean break the line(s) in the intersections?
try this macro (ordinate the selections):

with snippet picked in forum Making a Face from makeWire()

Configuration:
_________________________________________________
# if createWire = 0 create face
# if createWire = 1 create Line
# if createWire = 2 create point in intersection
# if createWire = 3 or other create face Line point

_________________________________________________

Code: Select all

#Macro_D_Un_Jour_Creer_Une_Face_Entre_Intersection_Lignes.FCMacro
#https://forum.freecadweb.org/viewtopic.php?f=3&t=58619
#14/05/2021
#mario52, Chris_G

import DraftGeomUtils, Draft
sel = FreeCADGui.Selection.getSelection()

####Configuration ###########
#
createWire = 0      #  if createWire = 0 create face 
                    #  if createWire = 1 create Line
                    #  if createWire = 2 create point in intersection
                    #  if createWire = 3 or other create face Line point
#
####Configuration ###########

try:
    if createWire == 0 or createWire > 2:
        points = []
        verts = []
        for i in range(len(sel)):
            verts.append(DraftGeomUtils.findIntersection(sel[i-1].Shape.Edges[0],sel[i].Shape.Edges[0]))
            points.append([verts[i][0][0], verts[i][0][1], verts[i][0][2]])  
        
        #https://forum.freecadweb.org/viewtopic.php?t=31082#p257798
        #Making a Face from makeWire()
        vecs = [FreeCAD.Vector(t) for t in points] # convert tuples to vectors
        vecs.append(vecs[0]) # to close the wire
        wire = Part.makePolygon(vecs)
        face = Part.Face(wire)
        Part.show(face)
        App.ActiveDocument.ActiveObject.Label = "ShapeFace"
    
    if createWire == 1 or createWire > 2:
        points = []
        for i in range(len(sel)):
            points.append(DraftGeomUtils.findIntersection(sel[i-1].Shape.Edges[0],sel[i].Shape.Edges[0]))
    
        for i in range(len(points)):    # create Line between 2 points
            try:
                line = Draft.makeLine(points[i][0],points[i+1][0])
            except Exception:
                line = Draft.makeLine(points[i][0],points[0][0])
        Draft.autogroup(line)
    
    if createWire == 2 or createWire > 2:
        points = []
        for i in range(len(sel)):
            points.append(DraftGeomUtils.findIntersection(sel[i-1].Shape.Edges[0],sel[i].Shape.Edges[0]))
            point = Draft.makePoint(points[i][0])
        Draft.autogroup(point)

except Exception:
    print("Error selection or ...")

Face_Entre_Intersection00.gif
Face_Entre_Intersection00.gif (251.46 KiB) Viewed 780 times

enjoy

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting, Dialog creation. My macros on Gist.github.
jtm2020hyo
Posts: 565
Joined: Wed Aug 12, 2020 1:24 am

Re: Create Face object using Edges intersections

Postby jtm2020hyo » Fri May 14, 2021 8:53 pm

thanks to everyone for the help.

Image

I found the trim command but do this individually was too hard when I try create a experimental custom Stair. the script pubished help a lot, is awesome is possible to modify it to work with Sketcher WB to trim multiple objects?.

... in this point, using manual trim, I found another problem here, the famous Topological naming problem attack again...

is there any method to create edit with multiple trim my Sketcher Object without modify my face objects?

normal:

Image

after edit:

Image
Attachments
Project-014.FCStd
(372.27 KiB) Downloaded 13 times
chrisb
Posts: 35270
Joined: Tue Mar 17, 2015 9:14 am

Re: Create Face object using Edges intersections

Postby chrisb » Fri May 14, 2021 9:43 pm

jtm2020hyo wrote: Fri May 14, 2021 8:53 pm is there any method to create edit with multiple trim my Sketcher Object without modify my face objects?
No. Not in master FreeCAD.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
jtm2020hyo
Posts: 565
Joined: Wed Aug 12, 2020 1:24 am

Re: Create Face object using Edges intersections

Postby jtm2020hyo » Sun May 16, 2021 6:54 pm

I think this is a very problematic bug in sketcher, also is related to topological naming problem.


image-1: 1D objects
Image

in image-1 i wish to try cut the extruded solid of the rectangle using sketcher lines like image-2

image-2: Part Design extruction
Image

image-3: result and bug

Image

image-3 show how i did a exploded-slice using object in image-1, but appears just 3 cuts when should be 6.

image-4: analysis

Image

in image-4 we can apprecite that the unique correct cut appears where are 3 vertex, the others 2 errors appears where are 1 vertex attached to 1 line and zero vertex with 1 crossing between 2 lines.

Conclusion: this error does not appears using Draft WB lines, just with SKetcher. To create a Exploded-Slice is need cut our lines to create 1 vertex per line in each intersection in SKetcher, and very sure is a bug and need fix.


EDIT: tested in 0.19 and 0.20

Code: Select all

OS: Windows 10 (10.0)
Word size of FreeCAD: 64-bit
Version: 0.20.24847 (Git)
Build type: Release
Branch: master
Hash: 20e756306d9aa624fcbf465f0345d721673ce720
Python version: 3.9.2
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.1
Locale: Spanish/Peru (es_PE)
Attachments
possible-bug-sketcher.FCStd
(23.78 KiB) Downloaded 13 times
chrisb
Posts: 35270
Joined: Tue Mar 17, 2015 9:14 am

Re: Create Face object using Edges intersections

Postby chrisb » Sun May 16, 2021 8:24 pm

I don't see anything wrong in Sketcher here. It may be discussed though, if the interpretation of the sketch by the slice command is correct.

Can you add a second object to your model with the working draft based slice?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
jtm2020hyo
Posts: 565
Joined: Wed Aug 12, 2020 1:24 am

Re: Create Face object using Edges intersections

Postby jtm2020hyo » Sun May 16, 2021 8:48 pm

here another test:

in this test, this error appears in Draft WB and Sketcher WB

image-5: I used circles and rectangles with my fixed (right) and unfixed Sketchers/Draft objects (left)

Image

for the fixed Sketcher/Draft objects (right) I just separated each line and vertex and was mentioned in image-4

image 6:

Image

I did extrude + exploded-Slice and the fixed Sketcher WB and Draft WB objects work correctly


edit:

conclusion: this is a general error/bug in FreeCAD, probably appears in all other WB

edit2:

i forget mention that in the image5 and image6 the Sketcher objects are top and Draft objects are bottom

Code: Select all

OS: Windows 10 (10.0)
Word size of FreeCAD: 64-bit
Version: 0.20.24847 (Git)
Build type: Release
Branch: master
Hash: 20e756306d9aa624fcbf465f0345d721673ce720
Python version: 3.9.2
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.1
Locale: Spanish/Peru (es_PE)
Attachments
possible-bug-sketcher1.FCStd
(89.28 KiB) Downloaded 10 times