help with sketcher: How to constrain a line segment to the x axis

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

help with sketcher: How to constrain a line segment to the x axis

Post by carlopav »

Hello, this is an help request to use PointOnObject to fix a line segment to the x axis. I tried with:

Code: Select all

Sketch.addConstraint(Sketcher.Constraint('PointOnObject',0,0,LineFixed))
Assuming that i'm constraining object 0 (the line segment), its point 0 (start point), but I can't understand what to put on LineFixed.
many thanks
follow my experiments on BIM modelling for architecture design
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: help with sketcher: How to constrain a line segment to the x axis

Post by openBrain »

Hi,

First, endpoints are identified with 1 & 2, not with 0 & 1. ;)
Then Xaxis is identified with -1 and Yaxis with -2. So :

Code: Select all

Sketch.addConstraint(Sketcher.Constraint('PointOnObject',0,1,-1))
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: help with sketcher: How to constrain a line segment to the x axis

Post by carlopav »

Thanks so much!
follow my experiments on BIM modelling for architecture design
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: help with sketcher: How to constrain a line segment to the x axis

Post by openBrain »

carlopav wrote: Sat Nov 30, 2019 2:32 pm Thanks so much!
Welcome. You know, for such things, you can do it in the GUI and observe the line appearing in the Python console to get clues about usage. ;)
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: help with sketcher: How to constrain a line segment to the x axis

Post by carlopav »

Yup that's how I usually do it, but I didn't find the information about -1 for X axis... Should we add the example to the wiki?
follow my experiments on BIM modelling for architecture design
chrisb
Veteran
Posts: 54150
Joined: Tue Mar 17, 2015 9:14 am

Re: help with sketcher: How to constrain a line segment to the x axis

Post by chrisb »

Extending the wiki is always a good idea.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply