Using LCS in TechDrawViews

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
wandererfan
Veteran
Posts: 6321
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Using LCS in TechDrawViews

Post by wandererfan »

Since this topic goes beyond Complex Section, I've split the discussion from here: https://www.forum.freecadweb.org/viewto ... 21#p647021
FBXL5 wrote: Mon Dec 12, 2022 1:20 am They are almost useless. It shows the center of the view. What is the use of this information?
They were added years ago as an aid to the programmer more than anything else. They were a big help in figuring out if I'd messed up the graphics, but they have probably outlived their usefulness now. I don't think they would be missed if removed or morphed into something more useful.
FBXL5 wrote: Should I want to cut through the center of a rotation object with some cut-away area I needed its rotation axis not the view center. This example cone's rotation axis is the 3D Z axis and its bottom face is coplanar with the 3D XY plane. I would expect that the center lines of the views represent the 3D X, Y and Z axes, but instead the axes have to be extracted manually (red X, green Y and blue Z axes, all dash-dot-dot)
Adding global axes to a view is easy using Python, but a property or button would be nicer:

Code: Select all

>>> view = App.ActiveDocument.View
>>> vx0 = App.Vector(100.0,0,0)
>>> vx1 = App.Vector(-100.0,0.0)
>>> view.makeCosmeticLine3D(vx0, vx1)
>>> vz0 = App.Vector(0.0, 0.0, 100.0)
>>> vz1 = App.Vector(0.0, 0.0, -100.0)
>>> view.makeCosmeticLine3D(vz0, vz1)
Adding lines for an object's LCS is harder. LCS can't be drawn currently as the shape is infinite and we won't know how to build a representation of the infinite shape until the rest of the view is created (to know the size). Then there is the problem of knowing which LCS to use in something like an assembly where there are many LCS.
FBXL5 wrote: Handling cosmetic geometry is still a pain; that's why I whish to have a draftster, a sketcher-like tool to create cosmetic geometry in a view and according to a view's local UV coordinate system - but that's another topic.
And a big one! :)
Attachments
ViewOfRotatedObjectWithGlobalAxes.png
ViewOfRotatedObjectWithGlobalAxes.png (32.03 KiB) Viewed 2317 times
User avatar
jpg87
Posts: 809
Joined: Thu Mar 16, 2017 7:16 am
Location: Limoges - France
Contact:

Re: Using LCS in TechDrawViews

Post by jpg87 »

wandererfan wrote: Mon Dec 12, 2022 7:04 pm FBXL5 wrote:
Handling cosmetic geometry is still a pain; that's why I whish to have a draftster, a sketcher-like tool to create cosmetic geometry in a view and according to a view's local UV coordinate system - but that's another topic.

And a big one!
It would indeed be great to have this kind of sketcher, maybe on an extra layer!
My website : http://help-freecad-jpg87.fr updated 2023/11/06
User avatar
FBXL5
Posts: 992
Joined: Sat Aug 03, 2019 8:45 pm

Re: Using LCS in TechDrawViews

Post by FBXL5 »

wandererfan wrote: Mon Dec 12, 2022 7:04 pm Adding global axes to a view is easy using Python, but a property or button would be nicer:
Such a button to create repersentations of global axes would be great for objects that demand a certain space within a global CS automotive or aviation parts or assemblies.
A small tripod should be enough for representation.

It took me a while to use the Python magic with the views of a ProjGroup, but I scceeded:
Snip macro screenshot-4ad69c.png
Snip macro screenshot-4ad69c.png (12.13 KiB) Viewed 2231 times
wandererfan wrote: Mon Dec 12, 2022 7:04 pm Adding lines for an object's LCS is harder.
I didn't mean the LCS of an object but the Local_CS object in the Tree view (PartDesign::CoordinateSystem).

Now independent views derived from the current camera position and views belonging to a ProjGroup can be used as base views to create another view (sections and complex sections at the moment and hopefully soon auxiliary views).
It seems like only views using a single (and simple?) transformation related to the global CS can be used as base views.

The idea is that a section or aux view has its own related 3D CS (Local_CS object) to represent it in the 3D space and so enabling it to be used as base views, if this makes sense. They could be placed on a layer that is hidden by default to not interfere with LCSs of objects.
This way you could trace chains of views outside of TechDraw if needed.

Rotated views have no X, Y, and Z axes but usually U and V axes instead. I'd prefer to call them like this (and not local X and Y axes).
The U and V coordinates of the view relate 1:1 with the X and Y coordinates of the corresponding Local_CS object and so, if needed, geometric additions to a view could be transferred back into 3D space without further calculation.
And if we could measure the angle between a line and the U axis it would be great if we could use this angle in the View Direction combo-box with just one click.

I'm sorry for some repetitions... :roll:
User avatar
FBXL5
Posts: 992
Joined: Sat Aug 03, 2019 8:45 pm

Re: Using LCS in TechDrawViews

Post by FBXL5 »

Python can place the tripod in section views as well, but it doesn't rotate with the view:
Snip macro screenshot-53edb4.png
Snip macro screenshot-53edb4.png (20.74 KiB) Viewed 2061 times
Snip macro screenshot-4b48f1.png
Snip macro screenshot-4b48f1.png (20.14 KiB) Viewed 2061 times

Code: Select all

OS: macOS 10.15
Word size of FreeCAD: 64-bit
Version: 0.21.0.31271 (Git)
Build type: Release
Branch: master
Hash: 1189be75d044e87cb55c74344405f4e484d57ddc
Python 3.10.8, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: C/Default (C)
Installed mods: 
  * Reinforcement
  * fcgear 1.0.0
  * Render 2022.2.0
  * fcgear.backup1662890180.767765
  * fasteners 0.4.21
  * CurvedShapes 1.0.4
  * sheetmetal 0.2.58
  * Help 1.0.3
  * Curves 0.5.12
  * Assembly3 0.11.3
user1234
Veteran
Posts: 3512
Joined: Mon Jul 11, 2016 5:08 pm

Re: Using LCS in TechDrawViews

Post by user1234 »

wandererfan wrote: Mon Dec 12, 2022 7:04 pm Since this topic goes beyond Complex Section, I've split the discussion from here: https://www.forum.freecadweb.org/viewto ... 21#p647021
I also link here my feature request, https://www.forum.freecadweb.org/viewto ... 07#p646807.
Just saying, it is not about using directly a LCS, it will result to using a defined origin point, a view direction and a horizontal or vertical direction, which leads to a LCS.

For example:

You have a shaft, and a some cosmetic elements, dimensions and so on.

When you change the geometry, so the bounding box changes, so the behavior is atm, that all is shifted from the middle of the bounding box, which is unpractical (you have to rearrange everything, not only what it have changed).

2022-12-27 21-02-41.png
2022-12-27 21-02-41.png (221.84 KiB) Viewed 1851 times

2022-12-27 21-03-20.png
2022-12-27 21-03-20.png (209.53 KiB) Viewed 1851 times

test52_TechDraw_positions.FCStd
(27.77 KiB) Downloaded 44 times

The middle line is not in the middle, the detail is shifted, the cosmetic vertexes are anymore in place. Ignore the TNP.


Referring this picture here https://www.forum.freecadweb.org/viewto ... 19#p646919, does set the hlr of OCCT the 0, 0, coordinate system automatic in the middle of the bounding box?

Greetings
user1234
User avatar
FBXL5
Posts: 992
Joined: Sat Aug 03, 2019 8:45 pm

Re: Using LCS in TechDrawViews

Post by FBXL5 »

user1234 wrote: Tue Dec 27, 2022 8:37 pm When you change the geometry, so the bounding box changes, so the behavior is atm, that all is shifted from the middle of the bounding box, which is unpractical (you have to rearrange everything, not only what it have changed).
I was surprised to discover that the view origin has nothing to do with any useful position other then the center of the bounding box, and that the view coordinate system is allways parallel to the page CS. Too bad that vectors used to create cosmetic points and lines (via Python script) are based on the same coordinate system and so they are as useless as the centerlines. :(

This makes sense for the positioning of the views on the page but not to set views in relation to each other. A local CS would be more helpful. Speaking of U and V coordinates gives the hint that they belong to a 2D CS in contrast to X, Y, and Z belong to a (global) 3D CS

Only the function makeCosmeticLine3D seems to deliver correctly projected cosmetic lines from 3D coordinates.
User avatar
wandererfan
Veteran
Posts: 6321
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Using LCS in TechDrawViews

Post by wandererfan »

FBXL5 wrote: Wed Dec 28, 2022 12:35 am
user1234 wrote: Tue Dec 27, 2022 8:37 pm
"It seems like only views using a single (and simple?) transformation related to the global CS can be used as base views."
>>> not sure about this. Any view can be a base view.

"Referring this picture here https://www.forum.freecadweb.org/viewto ... 19#p646919, does set the hlr of OCCT the 0, 0, coordinate system automatic in the middle of the bounding box?"
>>> no, we do this. If there are multiple objects in the view, they retain their relative positions, but the group's projection is centered on (0, 0) for drawing purposes. At some point in the process, we know the centroid of the object group, so we could retain that for further processing.


"I was surprised to discover that the view origin has nothing to do with any useful position other then the center of the bounding box, and that the view coordinate system is allways parallel to the page CS."
>>> the current center line functions run through the projected centroid of the source shapes (which isn't the same as the center of the view's rectangle). Yes, the lines run along the page's axes. We need better terminology too. To me the view's coordinate system is the ProjectionCS (centroid, Direction, XDirection) + translation(-centroid) + rotation (+ scale?), but the 2d cosmetic geometry uses ((0,0,0), Z, X)

"Only the function makeCosmeticLine3D seems to deliver correctly projected cosmetic lines from 3D coordinates."
>>> makeCosmeticVertex3d should also take a 3d point and place it correctly on the view.

I'm still struggling with this (as I do whenever I deal with multiple CS :(). I understand that the XY coordinates required to draw the figures is not ideal for the user, that the view's rotation and scale are part of the problem, and that makeCosmeticLine3D is better than makeCosmeticLine.

I also get that showing a projection of the the global 3d axes on the View would be helpful.

I don't understand what would be different with an LCS. I think I need some cartoons that show what the LCS would do or how it would be different from the current situation. My imagination just isn't up to the job.
user1234
Veteran
Posts: 3512
Joined: Mon Jul 11, 2016 5:08 pm

Re: Using LCS in TechDrawViews

Post by user1234 »

FBXL5 wrote: Wed Dec 28, 2022 12:35 am Too bad that vectors used to create cosmetic points and lines (via Python script) are based on the same coordinate system and so they are as useless as the centerlines.
That is the price for developing a CAD from (more or less) zero. I think no one ever guessed, that FreeCAD came that far.
wandererfan wrote: Wed Dec 28, 2022 6:49 pm I don't understand what would be different with an LCS. I think I need some cartoons that show what the LCS would do or how it would be different from the current situation. My imagination just isn't up to the job.
It is in fact a very hard to explain thing. Maybe i can show you something via videochat? (e.g. Jitsi, of course if you want, i will not force you to anything you do not want!)

Greetings
user1234
User avatar
FBXL5
Posts: 992
Joined: Sat Aug 03, 2019 8:45 pm

Re: Using LCS in TechDrawViews

Post by FBXL5 »

wandererfan wrote: Wed Dec 28, 2022 6:49 pm I don't understand what would be different with an LCS. I think I need some cartoons that show what the LCS would do or how it would be different from the current situation. My imagination just isn't up to the job.
I have tried to draw some images with Techdraw, but it is hard to show how auxiliary views could work if this functionality is not implemented yet and could hardly get worked around. And sketching auxiliary lines with cosmetic lines is a pain, because the angle can hardly be synchronised.

Since I still fail with images I'll have another try with words:

If there was a LCS that rotates with the view we could draw a line in the base view and measure the angle between this line and the (U or) X axis of that LCS.
The measured angle in relation with the direction vector of the base view should give the direction vector of a section or aux view.

Measuring points to a LCS should enable us to retranslate the coordinates into 3D space (global CS). This way section lines could be defined in the base view instead of somewhere in 3D space. The same applies for aux views.

At the moment I'm trying to find out how the direction vectors are used and how they change when rotating a view. Decades ago I learned how to "translate" vectors, but the memories have faded and I have to dig deep to rediscover them.
wandererfan wrote: Wed Dec 28, 2022 6:49 pm We need better terminology too. To me the view's coordinate system is the ProjectionCS (centroid, Direction, XDirection) + translation(-centroid) + rotation (+ scale?), but the 2d cosmetic geometry uses ((0,0,0), Z, X)
Geometric terminology is important and deserves an own wiki page to explain and exchange regional differences. I'm still unsure how to start this topic.
btw - is a centroid the same as a center of mass?
User avatar
wandererfan
Veteran
Posts: 6321
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Using LCS in TechDrawViews

Post by wandererfan »

FBXL5 wrote: Thu Dec 29, 2022 1:13 am btw - is a centroid the same as a center of mass?
The centroid is the geometric center of an object.

I think centroid == center of mass if the object has uniform density.
Post Reply