Query regarding face selection axis of structural element during reinforcement

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
amrit3701
Posts: 343
Joined: Mon Jun 13, 2016 5:37 pm

Query regarding face selection axis of structural element during reinforcement

Post by amrit3701 »

Hi,

I am a little bit confuse in the logic behind the present reinforcement system in FreeCAD. For eg. when we select any face of the structural element for reinforcement, how FreeCAD know which point (x-axis, y-axis or z-axis) from vertices of selected face should be neglected because sketcher is in 2D? In simple, we will neglect that axis which is perpendicular to selected face.
Is there any command which tells us about the perpendicular axis to selected face or any other logic to achieve above?

As "FreeCADGui.Selection.getSelectionEx()[0]" command is used to find the information of the user selected element.

Regards,
Amritpal Singh
Github, Like my work, sponsor me!
User avatar
yorik
Founder
Posts: 13630
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Query regarding face selection axis of structural element during reinforcement

Post by yorik »

the perpendicular direction of a face is called a normal. A flat face has only one normal, but a curved face has a different normalfor every point on the surface.

To find the normal of a face is easy, Part faces have a normalAt(x,y) method, where x and y are surface parameters. For a flat face, where all points have the same normal, myFace.normalAt(0,0) will give you the normal direction.
User avatar
amrit3701
Posts: 343
Joined: Mon Jun 13, 2016 5:37 pm

Re: Query regarding face selection axis of structural element during reinforcement

Post by amrit3701 »

yorik wrote:the perpendicular direction of a face is called a normal. A flat face has only one normal, but a curved face has a different normalfor every point on the surface.

To find the normal of a face is easy, Part faces have a normalAt(x,y) method, where x and y are surface parameters. For a flat face, where all points have the same normal, myFace.normalAt(0,0) will give you the normal direction.
I think this function gives normal vector w.r.t global axis but I require normal vector w.r.t local axis of the object.
Can you put some light on neglecting perpendicular axis w.r.t to selected face of the object during reinforcement? How FreeCAD know about that axes (points)?

Regards,
Amritpal Singh
Github, Like my work, sponsor me!
User avatar
yorik
Founder
Posts: 13630
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Query regarding face selection axis of structural element during reinforcement

Post by yorik »

amrit3701 wrote:I think this function gives normal vector w.r.t global axis but I require normal vector w.r.t local axis of the object.
Then you just need to transform that normal vector with the inverse of the object's rotation:

Code: Select all

normal = someFace.normalAt(0,0)
normal = myObject.Placement.Rotation.inverted().multVec(normal)
I don't understand well your other question?
User avatar
amrit3701
Posts: 343
Joined: Mon Jun 13, 2016 5:37 pm

Re: Query regarding face selection axis of structural element during reinforcement

Post by amrit3701 »

yorik wrote:
amrit3701 wrote:I think this function gives normal vector w.r.t global axis but I require normal vector w.r.t local axis of the object.
Then you just need to transform that normal vector with the inverse of the object's rotation:

Code: Select all

normal = someFace.normalAt(0,0)
normal = myObject.Placement.Rotation.inverted().multVec(normal)
I don't understand well your other question?
Okay, but I got a solution of my question from your above reply. :)

I tried some experimentation to understand the functioning of rebaring sketch in FreeCAD. I observed the following:
I made a structure in FreeCAD irrespective of its dimensional inputs and then tried rebaring on any of its faces. The origin of the sketch is located at the centre of the face only when if that face is perpendicular to the largest length/width/height. Check the screenshots with this post.

Here length is greater than width and height and the selected highlighted face which is perpendicular to the face which have maximium length.
length_greater.png
length_greater.png (129.17 KiB) Viewed 2399 times
The origin of the sketch is located at the centre of the selected face.
length_greater_s.png
length_greater_s.png (107.16 KiB) Viewed 2399 times
And the above method/experiment is followed when height is greater than length and width. But this experiment is not followed, when width is greater than length and height of the sturcture element because origin of the sketch is not located at the centre of the face selected face (which is perpendicular to the face having maximium length). For eg
width_greater.png
width_greater.png (134.89 KiB) Viewed 2399 times
The origin of the sketch is not located on the center of the face except it is located on the left side.
width_greater_s.png
width_greater_s.png (109.39 KiB) Viewed 2399 times
Kindly help me with this for more better understanding.

Thank you,
Amritpal Singh
Github, Like my work, sponsor me!
User avatar
yorik
Founder
Posts: 13630
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Query regarding face selection axis of structural element during reinforcement

Post by yorik »

The location of the sketch when you create it doesn't depend on Arch parameters (the Sketcher uses its own system). This system has changed a lot in 0.17, but basically the origin of the sketch has not much importance, what is important is that it lies on the correct face. It might be easier to first create the sketch (outside of the rebar function), then use the rebar tool with both the structhre and the sketch selected.
User avatar
amrit3701
Posts: 343
Joined: Mon Jun 13, 2016 5:37 pm

Re: Query regarding face selection axis of structural element during reinforcement

Post by amrit3701 »

yorik wrote:The location of the sketch when you create it doesn't depend on Arch parameters (the Sketcher uses its own system). This system has changed a lot in 0.17, but basically the origin of the sketch has not much importance, what is important is that it lies on the correct face. It might be easier to first create the sketch (outside of the rebar function), then use the rebar tool with both the structhre and the sketch selected.
You are right, the origin of the sketch has not much importance but while creating a sketch from FreeCAD UI because it automatically takes/generates points when user will draw sketch (say straight line) in the FreeCAD UI.

But the location of sketch's origin is important while creating a sketch from the program. For eg.
Let's take an example of straight rebar and we know that for drawing sketch of straight rebar we need the values two points (let's say A and B). Only two user input values will be needed to draw the sketch of straight rebar, first is side cover (distance between sketch end to its perpendicular face) say 's' and the second is a bottom cover (distance between sketch and a bottom face of the structure element) say 'b'. Also, L and W be the length and width of the face on which sketch is drawn respectively.

Case 1: When origin is located at the centre of the structural element.
length_greater_s.png
length_greater_s.png (107.16 KiB) Viewed 2319 times
The formula for calculating values of A and B:
A = -(L/2)+s, -(W/2)+b
B = (L/2)-s, -(W/2)+b


Case 2: When origin is located at the left side of the structural element.
width_greater_s.png
width_greater_s.png (109.39 KiB) Viewed 2319 times
The formula for calculating the values of A and B:
A = s, -(W/2 )+b
B = L-s, -(W/2)+b


At last, then the values of these points (A & B) will pass to sketch.addGeometry(Part.LineSegment(App.Vector(A[0], A[1], 0), App.Vector(B[0], B[1], 0)), False) which will drawn the sketch of straight rebar.

From all above, it should be cleared that the formula for calculating the values of A and B is fully dependent on the location of sketch's origin.

Comments are welcome. :)

Regards,
Amritpal Singh
Github, Like my work, sponsor me!
User avatar
amrit3701
Posts: 343
Joined: Mon Jun 13, 2016 5:37 pm

Re: Query regarding face selection axis of structural element during reinforcement

Post by amrit3701 »

yorik wrote:The location of the sketch when you create it doesn't depend on Arch parameters (the Sketcher uses its own system). This system has changed a lot in 0.17, but basically the origin of the sketch has not much importance, what is important is that it lies on the correct face. It might be easier to first create the sketch (outside of the rebar function), then use the rebar tool with both the structhre and the sketch selected.
Hi Yorik,

What's your views on the scripts which I have shared in https://forum.freecadweb.org/viewtopic. ... 10#p170634.

My approach is basically depends upon the location of sketch origin on the face of the structural element as shown in https://forum.freecadweb.org/viewtopic. ... 20#p170178.

But I unable to find a logic behind the location of sketch origin on the face of the structural element. Every time when I change the dimension of the structural element and selecting the same face for reinforcement, the position of sketch origin is changed.

As you said in the above reply that location of sketch origin is not much important and what is important is that it lies on the correct face. Yes, it is right only when user will create reinforcement from FreeCAD UI. But the location of sketch plays an important role while drawing a sketch from programming.

Also, when length is greater than both width and height or width is greater than both length and height of the structure element, both will show same behaviour i.e. Front view (Gui.activeDocument().activeView().viewFront()) show Face3 and Top view (Gui.activeDocument().activeView().viewTop()) show Face4. But when height is greater than both length and width of the structure element, it will show different behaviour i.e. Front view show Face3 and Top view show Face5. Can you tell where are all the fundamentals is defined in the FreeCAD?

Regards,
Amritpal Singh
Github, Like my work, sponsor me!
User avatar
yorik
Founder
Posts: 13630
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Query regarding face selection axis of structural element during reinforcement

Post by yorik »

You hit one of the big problems of FreeCAD, which we call topology naming. Basically, each time OCC recomputes a shape, it can reorder subelements (edges, faces, etc) differently. At the moment, nobody was able to come with a good solution for that problem. (But one of the accepted GSOC projects is dealing with exactly that problem!)

Sometimes you just have to live with it (ie. when an object must relate to a face, you are well forced to indicate which face, there is no way around), but, as much as possible, you must think of solutions that don't rely on face/edge number.

About your scripts, that's good, that's basically the way to go, but I would not rely on the Arch makeRebar function. It is only there for didactic reasons (so when using the GUI, the user sees what's being executed in the python console in a simple form). I would study what the function does (basically just create a Rebar object). You will very likely have more freedom creating functions that directly create and manipulate Rebar objects.
markkc
Posts: 2
Joined: Sun May 28, 2017 5:22 pm

Re: Query regarding face selection axis of structural element during reinforcement

Post by markkc »

Hello,
I just recently tried freecad and I like it very much. I started testing Arch WB.
I am sorry for intruding this topic, but it seem best for my question.

I have a question regarding creation of ArchRebar on Structure element face: Why does This function create copy of Structure (Structure001) as a parent to Structure and Rebar?
ArchRebar.png
ArchRebar.png (203.77 KiB) Viewed 2030 times

Creating another Rebar on Parent (Structure001) will create another Parent Structure002, and so on...
ArchRebar1.png
ArchRebar1.png (169.11 KiB) Viewed 2030 times
I understand that rebar is child to Structure geometry, being defined by sketch I suggest, if possible to reduce number of Structure copying by simply place rebar as a child to original structure:
Structure
|-Rebar
|-Rebar001
|-Rebar002
...


As a Side note: Why not set Rebar property "Move with host" to True as default? Moving structural element will then take Rebar also.

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11300 (Git)
Build type: Release
Branch: master
Hash: 294551a2fb3a8e4a67e9013217af4d65fdcf30ae
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Post Reply