Alignment of view around the view axis

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
chrisb
Veteran
Posts: 54207
Joined: Tue Mar 17, 2015 9:14 am

Alignment of view around the view axis

Post by chrisb »

When adding a view to a TechDraw page, it can easily be aligned to the drawing plane, by selecting a flat face and then adding it to the page.
However, I didn't find a way to align the view around the viewing-axis orthogonal to the drawing plane. Is there such a possibility, or is it worth a feature request?

Example:
Given this object ...
SnipScreenshot-b347a4.png
SnipScreenshot-b347a4.png (24.99 KiB) Viewed 645 times
... I want to place the selected face on a TechDraw page so that it is aligned with the sides horizontally/vertically. This is what I get:
SnipScreenshot-db7c0a.png
SnipScreenshot-db7c0a.png (8.04 KiB) Viewed 645 times
It would be great, if in addition to the object I could select a line indicating the horizontal orientation.
Attachments
tiltedCube.FCStd
(10.08 KiB) Downloaded 24 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
domad
Veteran
Posts: 2094
Joined: Mon Jun 22, 2020 12:16 pm

Re: Alignment of view around the view axis

Post by domad »

Greetings to the Community!
Of course having this possibility would be good, however until the specific function arrives, currently it can be done as shown in the animated gif but it would become laborious to derive the exact sections.
So the new function should take into account the new alignment to obtain the correct sections.
Attachments
Alignment_tiltedCube_TechDraw.gif
Alignment_tiltedCube_TechDraw.gif (278.01 KiB) Viewed 570 times
chrisb
Veteran
Posts: 54207
Joined: Tue Mar 17, 2015 9:14 am

Re: Alignment of view around the view axis

Post by chrisb »

domad wrote: Sat Mar 18, 2023 8:04 amcurrently it can be done as shown in the animated gif
Thanks for the workaround! (It works here for the most common case where one of the lines on the drawing should be aligned. For an automated function, it would be nice to go beyond that, and allow any line from the 3D model as well.)
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
wandererfan
Veteran
Posts: 6320
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Alignment of view around the view axis

Post by wandererfan »

chrisb wrote: Sat Mar 18, 2023 10:21 am For an automated function, it would be nice to go beyond that, and allow any line from the 3D model as well.)

Code: Select all

view = App.ActiveDocument.View

# method 1 - angle is known & top view
import math
angle = math.radians(30)
cos = math.cos(angle)
sin = math.sin(angle)
newX = App.Vector(cos, sin, 0.0)
view.XDirection = newX

# method 2 - edge (line) is selected. should work for general case.
sel = Gui.Selection.getSelectionEx()
edge = sel[0].SubObjects[0]	# first subelement of first selected object
view.XDirection = edge.Curve.Direction
chrisb
Veteran
Posts: 54207
Joined: Tue Mar 17, 2015 9:14 am

Re: Alignment of view around the view axis

Post by chrisb »

wandererfan wrote: Sat Mar 18, 2023 1:14 pm ...
Thanks! That's much better than the eyeballing I did until now :D .
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply