Draft_PointArray beyond a "point object".

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
andrecaldas
Posts: 300
Joined: Fri Jan 27, 2023 8:45 pm
Contact:

Draft_PointArray beyond a "point object".

Post by andrecaldas »

Using Draft::PointArrays and alike, one can choose an object A to be replicated through a "point object" M. Conceptually, M is a collection of points that specify the number of copies and their placements. So, for each point p in M, one copy is produced and the copy's Placement.Position is set to p.

It would be nicer if the "point object" could specify not only Placement.Position, but also, Placement.Angle. And even, optionally, Placement.Scale. Instead of a "point object", it would be a line object. Right now, the way to do that, AFAIK, is to expose each copy via ExpandArray = true. And by the way, when you set back to false, you loose all manually entered values. :?

Instead of using only one point, by using a line --- two points p = (p1, p2) and q = (q1,q2) ---, each copy could be transformed by the augmented matrix

Code: Select all

[x1   -x2     p1]
[x2    x1     p2]
[0      0      1],
where x = q - p, if the new variable AutomaticallySetScale is set to true. Or, x would be normalized to make ||x|| = 1 when AutomaticallySetScale is set to false.


Even Better

It would be even better if we could have a Sketch (or another line object) containing a line PQ, associated to Base, to work as an anchor. That is, the transformation would be adjusted to map P to p and Q to q, in case AutomaticallySetScale is true. And in case it is false, the transformation would be adjusted to map P to p and
be such that the direction of PQ would be sent to the direction of pq.

The previous case is a special case of this Even Better functionality, where P = (0,0) and Q = (1,0).

Code: Select all

OS: Debian GNU/Linux bookworm/sid (GNOME/gnome)
Word size of FreeCAD: 64-bit
Version: 0.20.1.
Build type: Release
Python 3.10.8, Qt 5.15.6, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: C/Default (C)
Installed mods: 
  * parts_library
  * AnimationFreeCAD 1.0.0
  * dodo 1.0.0
  * BIM 2021.12.0
  * Reinforcement
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft_PointArray beyond a "point object".

Post by Roy_043 »

You are using an older version. Draft_PointArray accepts more point objects now. So please update to the current dev. version first.

What you are proposing seems very complex. Can you give an example of a practical application?
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Draft_PointArray beyond a "point object".

Post by onekk »

andrecaldas wrote: Mon Feb 06, 2023 9:17 am Using Draft::PointArrays and alike, one can choose an object A to be replicated through a "point object" M. Conceptually, M is a collection of points that specify the number of copies and their placements.
...

Placement has a precise mean in FreeCAD, so telling that you are simply saying that what you want is already doable.

A Placement could even be a Matrix a (4x4) matrix that in theory should even used for scaling, but Matrix Math is not my best knowledge, but see:

Code: Select all

help(FreeCAD.Matrix)
Help on class Matrix:

class Matrix(builtins.PyObjectBase)
 |  Base.Matrix class.
 |  
 |  A 4x4 Matrix.
 |  In particular, this matrix can represent an affine transformation, that is, given a
 |  3D vector `x`, apply the transformation y = M*x + b, where the matrix `M` is a linear
 |  map and the vector `b` is a translation.
 |  `y` can be obtained using a linear transformation represented by the 4x4 matrix `A`
 |  conformed by the augmented 3x4 matrix (M|b), augmented by row with (0,0,0,1), therefore:
 |  (y, 1) = A*(x, 1).
 |  
 |  The following constructors are supported:
 ....
however FreeCAD Matrix has already implemented scale method, see maybe:.

Code: Select all

help(FreeCAD.Matrix.scale)
Help on method_descriptor:

scale(...)
    scale(vector) -> None
    scale(x, y, z) -> None
    scale(factor) -> None
    
    Scale the first three rows of the matrix.
    
    vector : Base.Vector
    x : float
        First row factor scale.
    y : float
        Second row factor scale.
    z : float
        Third row factor scale.
    factor : float
        global factor scale.
See maybe:

https://wiki.freecad.org/Placement

When dealing with concepts, probably it is "a minimun requirement" to learn how things are done actually in FreeCAD and acquire a correct terminology.

If you want too complex things, probably a new function will be more taylored as probably the scope is different.

Or maybe this could be already be achieved using Lattice2 WB (hoping to have remembered well the name) that seem to make wonders, and is very flexible.

However it is not a problem, you could even write a Macro that do what you want and add to FreeCAD as a ToolBar button.

There are many ways of doing things in FreeCAD.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
andrecaldas
Posts: 300
Joined: Fri Jan 27, 2023 8:45 pm
Contact:

Re: Draft_PointArray beyond a "point object".

Post by andrecaldas »

onekk wrote: Mon Feb 06, 2023 11:41 am
andrecaldas wrote: Mon Feb 06, 2023 9:17 am Using Draft::PointArrays and alike, one can choose an object A to be replicated through a "point object" M. Conceptually, M is a collection of points that specify the number of copies and their placements.
...

Placement has a precise mean in FreeCAD, so telling that you are simply saying that what you want is already doable.

A Placement could even be a Matrix a (4x4) matrix that in theory should even used for scaling, [...]
I am sorry... I really fail to understand what you mean. You seem to imply that somehow I am proposing a different Placement implementation or that I am asking for help on how to use/set the Placement. The "quote" you made from the help on FreeCAD.Matrix does not say anything different from the link I had just posted about the so called augmented matrix.

I do not see how my post goes against or is inconsistent with the very precise meaning of Placement in FreeCAD. The matrix notation is just a mathematical way people like to use very much when they want to make the idea of "placement" precise. I am using a 3x3 matrix because I do not want to care for the normal vector, as it would simply make things more complicated. The normal vector is not affected by what I am proposing.

Probably I did not make my intentions clear. So, let me explain:
I am suggesting an improvement. That Draft::PointArray (and alike) be able to interpret not only points, but also lines in order to adjust not only the Placement.Position, but also the Placement.Angle and, optionally, Placement.Scale.
Let me avoid using the mathematical language of matrices, because people find them complicated and soon start debating about matrices, changing the discussion subject.

Given the line object (that would replace the point object), Position would be the line starting point. Angle would be the line angle, and Scale could be given by the size of the line (somehow). The normal vector is simply the normal to the plane for the given 2D object, as it probably is with point object, already.

Just to be clear, when I say "somehow" is not because it is not easy to do, or because I don't know how... it is just because further decisions need to be made and I think this part of the discussion can be postponed.

onekk wrote: Mon Feb 06, 2023 11:41 am See maybe:

https://wiki.freecad.org/Placement

When dealing with concepts, probably it is "a minimun requirement" to learn how things are done actually in FreeCAD and acquire a correct terminology.
I find your comment very unfair. I started using FreeCAD a couple of weeks ago. I have watched tons of videos and read pages and pages of https://wiki.freecad.org/. I do not understand the treatment I am receiving.

I am trying to use the correct terminology to my best. I have even mentioned augmented matrix representations of affine transforms, which are essentially the two most important keywords in the help quotations you gave me. I talked about the values of Placement.Scale, Placement.Angle and Placement.Position. This is all correct terminology as far as I am concerned. I do think my post is not badly written.

Or maybe this could be already be achieved using Lattice2 WB (hoping to have remembered well the name) that seem to make wonders, and is very flexible.
Maybe the Lattice2, and maybe the Assembly3 WB.

I did feel very comfortable in suggesting what I suggested because of the information at point object explanation. It says that the Draft::PointArray was introduced in version 0.18. And also, about the point objects it says:
These are the supported point objects in version 0.20 and below and how they can be created:
From that, I supposed:
1. The point object is a new concept in FreeCAD.
2. There is room for improvement.

I am suggesting what IMHO is a very nice improvement to the concept of point object.

There are many ways of doing things in FreeCAD.
Yes. :-)
And I am suggesting an improvement that hopefully would motivate people to do things in ways that are at the same time graphical and parametric. Notice that the point object can be bound to External Geometry.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Draft_PointArray beyond a "point object".

Post by onekk »

andrecaldas wrote: Mon Feb 06, 2023 1:45 pm find your comment very unfair. I started using FreeCAD a couple of weeks ago. I have watched tons of videos and read pages and pages of https://wiki.freecad.org/. I do not understand the treatment I am receiving.
Sorry if it has seem an attack to your person, as I and many people here are not native English speaker, some "bad choice of term and phrasing" has to be taken in account, so if I have offended you it was not my intention, as probably I have not spend my time to post some relevant information to corroborate my thinking, in the preceding post and in the actual.

Requesting an improvement prior to have investigated further if similar thing could be achieved in other ways, seems to be increasing this times.

Tons of video maybe outdated prior to have searched for advice here and maybe having read some wiki pages, is not sufficient to manage all the complexity of FreeCAD, see maybe:
https://wiki.freecad.org/FreeCAD_Managing_Expectations

---

About Placement and teminology, I was referring to this sentence:
...
replicated through a "point object" M. Conceptually, M is a collection of points that specify the number of copies and their placement
..
This is the Point about terminology when you speak about placement, you are speaking about a "precise FreeCAD concept", it is an object property that hold two things.

Rougly explanation is that it combine a a rotation and a translation.

A placement intended as above could be assigned in many ways, as example with a Matrix, or with a Quaternion, or even with a translation Vector a 3d Rotation and maybe a center of rotation.

In this sense I have suggested to learn a "minimum terminology" specific to FreeCAD.

FreeCAD has already the ability to assign whathever placement you want as example has 24 ways to specify a 3d rotation as the order in which you apply a 3d rotation could be relevant see as example "euler angles" item on Wikipedia (I know that is not scientifically correct but it gave an idea of what I'm speaking about).

Achieving it with GUI is not my best knowledge, but I apply and orient things like rivets on curved surface following the surface normal everyday, but usually writing scripts.

So my knowledge is more near the ability of FreeCAD in achieving things rather than obtaining them with the GUI.

However if you can specify only a point using Draft_Pointarray it is not surprising that you could specify only a point.

But that is not true as the Wiki page says you could even specify:
DataExtra Placement (Placement): : specifies an additional placement, translation and rotation, for each element in the array.
DataPoint Object (Link): specifies the compound object whose points are used to position the elements in the array.
I have not found a way to make what the wiki say about the Extra Placement I see that is a list, but I could not find a way to specify for each element copied a separate "placement property" If this wil be achievable the result will not be much far from what you are asking.


If this will not suffice probably Lattice2 WB at a first glance it could already do similar more complex things.

https://wiki.freecad.org/Lattice2_Workbench

Regards

Carlo D.

Post edited some times, to expalin better my intention, sorry if the WIP state has caused annoyances.
Last edited by onekk on Mon Feb 06, 2023 3:09 pm, edited 7 times in total.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft_PointArray beyond a "point object".

Post by Roy_043 »

Carlo, I do not doubt your good intentions, but you are giving a lecture that moves the focus away from the actual proposal.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Draft_PointArray beyond a "point object".

Post by onekk »

Roy_043 wrote: Mon Feb 06, 2023 2:42 pm Carlo, I do not doubt your good intentions, but you are giving a lecture that moves the focus away from the actual proposal.
Thanks you are right I have corrected the post, but as said probably in the new version, Draft_PointArray is perfect as is, IMHO as usual.

@Roy_043

As you are the editor of the Draft_PointArray page.

How to apply a separate placement for each element as the
DataExtra Placement (Placement): : specifies an additional placement, translation and rotation, for each element in the array.
Seem to say?

Regards

Carlo D.
Last edited by onekk on Mon Feb 06, 2023 3:13 pm, edited 1 time in total.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
andrecaldas
Posts: 300
Joined: Fri Jan 27, 2023 8:45 pm
Contact:

Re: Draft_PointArray beyond a "point object".

Post by andrecaldas »

onekk wrote: Mon Feb 06, 2023 2:20 pm Sorry if it has seem an attack to your person, as I and many people here are not native English speaker, some "bad choice of term and phrasing" has to be taken in account, so if I have offended you it was not my intention, as probably I have not spend my time to post some relevant information to corroborate my thinking, in the preceding post and in the actual.
I am very grateful for all your attention and the time you spend trying to help others! I know you had no intention to cause no harm.

Following your good advice, I guess Assembly3, Assembly4 or Lattice2 do what I need and even more. I have to study them, figure out the proper way to use them and decide which one to pick. Right now, I am learning about the differences between Assembly3 and Assembly4. :-)

Roy_043 wrote: Mon Feb 06, 2023 9:49 am What you are proposing seems very complex. Can you give an example of a practical application?
Well, it seems I do not really need it if I am going to use one of those Assembly WB. I don't think it is complex, but I did not study Draft::PointArray the source yet. (although I have already downloaded from github and compiled it)

If anyone has interest in it, I could give it a try. I think it is a nice improvement to Draft::PointArray.

As an example of application, in my case, I am migrating a house design from a PDF file. I made the walls. In many places, I'd like to put a column, which is an structural element. Each column needs to "snap" to the right position.See this post of mine. So, I would like to match two points of the column (object being replicated) to two points (one line) in the "point object". This would be the "even better" part on my first post.
freecad_wallguide.png
freecad_wallguide.png (118.25 KiB) Viewed 832 times
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Draft_PointArray beyond a "point object".

Post by onekk »

Assembly4 seem to be more "easy to learn" but is an impression.

When I have to do assemblies for me it is more easy to script things and directly assign placement.

But my way of using FreeCAD is quite peculiar, I almost script all my modelling work, and even when I use FCStd file are usually made with scripting to permit a more parametric approach, but is a not so easy approach.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft_PointArray beyond a "point object".

Post by Roy_043 »

andrecaldas wrote: Mon Feb 06, 2023 4:36 pm I don't think it is complex, but I did not study Draft::PointArray the source yet.
I was not thinking about the code when I used the word 'complex', but more about the user experience.
Post Reply