How to verify the direction of sketch lines?

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!
User avatar
Roy_043
Veteran
Posts: 8550
Joined: Thu Dec 27, 2018 12:28 pm

How to verify the direction of sketch lines?

Post by Roy_043 »

In the Arch WB you can use a sketch as a base for a wall. The direction of the sketch lines is important if the alignment of the wall is Left or Right instead of Center. Is there a way to visually verify the direction of sketch lines?
chrisb
Veteran
Posts: 54195
Joined: Tue Mar 17, 2015 9:14 am

Re: How to verify the direction of sketch lines?

Post by chrisb »

In the "Elements" section of the left Sketcher panel you can switch from type "Edge" to "Start point". If you now select an element in the list it will show the start point in 3D view.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
papyblaise
Veteran
Posts: 8000
Joined: Thu Jun 13, 2019 4:28 pm
Location: France

Re: How to verify the direction of sketch lines?

Post by papyblaise »

Hello
No , any possibility , but an smol idea :
if you have a single vertex , rigth direction is NE/SE side , oposit is : left NW/SW
If you have close sketch (rectangle or more) right is outside , left is inside the figur
User avatar
Roy_043
Veteran
Posts: 8550
Joined: Thu Dec 27, 2018 12:28 pm

Re: How to verify the direction of sketch lines?

Post by Roy_043 »

Thanks.

@chrisb:
That works. But in case of lines with a coincident constraint it is impossible to tell to which line the point belongs. Combining Edge+Start Point would be clearer.
chrisb
Veteran
Posts: 54195
Joined: Tue Mar 17, 2015 9:14 am

Re: How to verify the direction of sketch lines?

Post by chrisb »

That's indeed worth a consideration, although it may be unhandy when the task is to select several points and you always have to deselect the edges.
Abdullah wrote:ping
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
mario52
Veteran
Posts: 4692
Joined: Wed May 16, 2012 2:13 pm

Re: How to verify the direction of sketch lines?

Post by mario52 »

hi

for see the begin and the end line tray this macro
(related here)

Code: Select all

# -*- coding: utf-8 -*-
# https://forum.freecadweb.org/viewtopic.php?f=3&t=29148
# https://forum.freecadweb.org/viewtopic.php?f=3&t=38660&p=328132#p328132
# Macro_Begin_End
# 07/06/2018 20/08/2019

import Draft
try:
    sel = FreeCADGui.Selection.getSelection()
    name = sel[0].Name
    
    boundBox_ = sel[0].Shape.BoundBox
    boundBoxDiag = boundBox_.DiagonalLength
    #print( boundBoxDiag)
    
    SubElement = FreeCADGui.Selection.getSelectionEx()   
    sbName = SubElement[0].SubElementNames[0]
    print( sbName)
    
    SubElement = Gui.Selection.getSelectionEx()[0].SubObjects[0].Vertexes
    #print SubElement[0].Point
    txtBegin = Draft.makeText(["Begin"],point=FreeCAD.Vector(SubElement[0].Point)) # create text Begin
    txtBegin.ViewObject.FontSize = float(boundBoxDiag)/10.0
    txtBegin.Label = name + "_" + sbName + "_Begin"
    
    #print( SubElement[1].Point)
    txtEnd = Draft.makeText(["End"],point=FreeCAD.Vector(SubElement[1].Point))     # create text End
    txtEnd.ViewObject.FontSize = float(boundBoxDiag)/10.0
    txtEnd.Label = name + "_" + sbName + "_End"

    #direction of element
    ##SubElement = Gui.Selection.getSelectionEx()[0].SubObjects[0].Vertexes
    print(SubElement[0].Vertexes[0].Point)
    print(SubElement[1].Vertexes[0].Point)
    
    direction = SubElement[1].Vertexes[0].Point.sub(SubElement[0].Vertexes[0].Point)
    print( "Direction axis = ", direction)
    print("___________________________________________")
except Exception:
    print( "oups")


Image

EDIT: 21/08/2019 11h18 Paris modify the code adding direction of the object (subObject) selected and the label is renamed name_subObject
ex: Sketch_Edge3_Begin ... Sketch_Edge3_End

mario
Last edited by mario52 on Wed Aug 21, 2019 9:23 am, edited 1 time in total.
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
Roy_043
Veteran
Posts: 8550
Joined: Thu Dec 27, 2018 12:28 pm

Re: How to verify the direction of sketch lines?

Post by Roy_043 »

Thanks Mario. The code works on Draft lines and edges of solids, but not on sketches.

Some background info:
In a sketch 'loop' segments are not necessarily connected start to end. When you use such a loop as the base for a wall somehow a single direction is determined. I am trying to understand this behavior.
mario52
Veteran
Posts: 4692
Joined: Wed May 16, 2012 2:13 pm

Re: How to verify the direction of sketch lines?

Post by mario52 »

hi

the macro work also with sketch (one seperate element)

DirectionElement00.gif
DirectionElement00.gif (119.79 KiB) Viewed 1282 times
or I not understand (a single direction is determined)

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
Roy_043
Veteran
Posts: 8550
Joined: Thu Dec 27, 2018 12:28 pm

Re: How to verify the direction of sketch lines?

Post by Roy_043 »

@mario52:
Ah, yes it does work. Thanks for the code and the animation.

Here is an image to better explain the issue.
The orthogonal lines in both sketches were created in a CCW direction starting with the line on the X axis.
The start point of the diagonal line in the 2nd sketch is closer to the Y axis than its end point. So its direction is opposite to the other 3 lines in the sketch.
Both walls have the Align property set to Left.

Somehow the sketch 'loop' on the right is interpreted as having a CW direction. I am wondering what logic applies here. My first conclusion was that the last element in the loop (irrespective of its position in the loop) determines the overall direction. But further experiments have shown that this does not always apply.
Attachments
Wall_Dir.FCStd
(17.81 KiB) Downloaded 27 times
Wall_Dir.png
Wall_Dir.png (11.27 KiB) Viewed 1258 times
mario52
Veteran
Posts: 4692
Joined: Wed May 16, 2012 2:13 pm

Re: How to verify the direction of sketch lines?

Post by mario52 »

hi

if the object is modified it is completely recalculated (new object)

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
Post Reply