How to set a slope of x.x %

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!
Post Reply
t.lemaitre
Posts: 34
Joined: Sat Feb 23, 2019 11:18 pm

How to set a slope of x.x %

Post by t.lemaitre »

Hi,

I'm using de the Draft Slope tool to build pipe:
https://www.freecadweb.org/wiki/Draft_Slope

However, I didn't find how to set a slope between two round values in % : I mean 0.5% or 2.3% for example.

It's quite strange because it seem possible if you read the wiki page precited.

Any idea to help me?
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: How to set a slope of x.x %

Post by vocx »

t.lemaitre wrote: Sat Oct 19, 2019 11:08 pm ...
However, I didn't find how to set a slope between two round values in % : I mean 0.5% or 2.3% for example.
...
What is a slope of 5% in degrees? What about 2.3%? What do these numbers indicate?

Is 100% equal to 90 degrees? Measuring a slope in percentage may be a convention used in some fields, but it isn't very precise. It should be measured in degrees, or as the tangent of the angle of aperture.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
chrisb
Veteran
Posts: 54201
Joined: Tue Mar 17, 2015 9:14 am

Re: How to set a slope of x.x %

Post by chrisb »

vocx wrote: Sun Oct 20, 2019 2:01 am Is 100% equal to 90 degrees?
No, it's 45°. The percentage is in a rectangular triangle with one side horizontal and one side vertical the ratio of the length of the vertical line divided by the length of the horizontal line. So it is in fact the tangent function.

Measuring a slope in percentage may be a convention used in some fields, but it isn't very precise.
It is e.g. used for waste water pipes and it is very very precise. Tell a channel digger to place the tubes at an angle of 0.572939° and he will call you an idiot. Tell him he should have a drop of 1cm per meter is easy to implement.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
t.lemaitre
Posts: 34
Joined: Sat Feb 23, 2019 11:18 pm

Re: How to set a slope of x.x %

Post by t.lemaitre »

Ok, now everybody speaks about the same thing : tangent is equal to percent of slope.

So, are you able to set a slope between two round values in % : I mean 0.5% or 2.3% for example?
If yes, I'd like to know how.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: How to set a slope of x.x %

Post by vocx »

chrisb wrote: Sun Oct 20, 2019 6:40 am No, it's 45°.
Okay, so it has a definition. I wonder why OP doesn't use it then.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to set a slope of x.x %

Post by openBrain »

vocx wrote: Sun Oct 20, 2019 2:34 pm Okay, so it has a definition. I wonder why OP doesn't use it then.
Sure it has a definition. ;) The most universal usage (IMO) is for road grade.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to set a slope of x.x %

Post by openBrain »

t.lemaitre wrote: Sun Oct 20, 2019 12:10 pm Ok, now everybody speaks about the same thing : tangent is equal to percent of slope.

So, are you able to set a slope between two round values in % : I mean 0.5% or 2.3% for example?
If yes, I'd like to know how.
You can't set values with 1/1000 precision as the input control is a QDoubleSpinBox that has a decimal precision of 2 (it's the default value in Qt). ;)
As a workaround you can :

1. Hack a file
Go to this file @ this line and add a new line with same indentation with :

Code: Select all

self.spinbox.setDecimals(XXX)
Where 'XXX' is the decimal precision (eg. 3 if you want 1/1000 numbers)

This hack will create a permanent change but will (IMO) be overwritten when a new version is available.

2. Hack the GUI
Click on the Draft/SetSlope function to display the slope input field in the Task panel, then enter following in the Python Console :

Code: Select all

from PySide import QtCore, QtGui
QtCore.QTimer.singleShot(2500, lambda:QtGui.QApplication.focusObject().setDecimals(XXX))
Where 'XXX' is the decimal precision.
After validating the 2nd line, you get 2.5 seconds to set the cursor on the slope input field. :) When delay expires, the precision is changed. ;)

This hack is a single shot one. ;)

I almost never use Draft, so I won't discuss if it's right or wrong that this input field is limited to 2 decimals, if it should be aligned with application decimals, ... :P

EDIT : if you want same precision as application, use following as 'XXX' value :

Code: Select all

App.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("Decimals")
t.lemaitre
Posts: 34
Joined: Sat Feb 23, 2019 11:18 pm

Re: How to set a slope of x.x %

Post by t.lemaitre »

openBrain wrote: Sun Oct 20, 2019 5:19 pm 2. Hack the GUI
Click on the Draft/SetSlope function to display the slope input field in the Task panel, then enter following in the Python Console :

Code: Select all

from PySide import QtCore, QtGui
QtCore.QTimer.singleShot(2500, lambda:QtGui.QApplication.focusObject().setDecimals(XXX))
Where 'XXX' is the decimal precision.
After validating the 2nd line, you get 2.5 seconds to set the cursor on the slope input field. :) When delay expires, the precision is changed. ;)
I tried it and it works! Thanks ;)
Post Reply