[Feature Request] Add a way to align section views to regular views

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
NewJoker
Veteran
Posts: 3079
Joined: Sun Oct 11, 2020 7:49 pm

Re: [Feature Request] Add a way to align section views to regular views

Post by NewJoker »

edi wrote: Thu Mar 10, 2022 9:51 am Please test the macro. Is it worth to create an extension tool in TechDraw ? Pease tell me your opinion.
I tested it. Works just as expected. It would be great if you could turn this into a built-in functionality - would be very useful.

Here's a simple test example:

- before:

before.PNG
before.PNG (42.24 KiB) Viewed 2271 times

- after:

after.PNG
after.PNG (42 KiB) Viewed 2271 times
balrobs
Posts: 449
Joined: Fri Apr 24, 2020 8:58 pm

Re: [Feature Request] Add a way to align section views to regular views

Post by balrobs »

I also vote for a built-in functionality ... however I would suggest to not create a new command but rather enhache the existing "Position section view"
Cheers
ToniTen
Posts: 242
Joined: Fri Sep 04, 2020 10:11 am

Re: [Feature Request] Add a way to align section views to regular views

Post by ToniTen »

edi wrote: Thu Mar 10, 2022 9:51 am Find attached my version of the macro (hopefully) doing the task:

Workflow:
- select one point in the base view
- select the corresponding point in a section view
- start the macro

The section view is positioned at the correct perpendicular position.

Attention: There is no test, whether the correct objects are selected.

Please test the macro. Is it worth to create an extension tool in TechDraw ? Pease tell me your opinion.
Tested, and it is extremely nice. I would love having it added by default as an Extension Tool.

Question, how tricky would it be to allow for one or both of the selected geometry elements to be a line segment, and then create a temporary vertex at [min x|max x], [min y|max y] (depending on what's more appropriate based on the position of the two views) that is finally used to align the views? If this functionality was added, I would not mind if the align function was split into AlignViewX and AlignViewY
User avatar
proghettolab
Posts: 52
Joined: Sat Jun 27, 2020 3:09 pm

Re: [Feature Request] Add a way to align section views to regular views

Post by proghettolab »

Nice macro.
It would be very useful to obtain the two alignments, x and y, and even make the points coincide.

pMB
edi
Posts: 482
Joined: Fri Jan 17, 2020 1:32 pm

Re: [Feature Request] Add a way to align section views to regular views

Post by edi »

A short script to coincide two points of two different views in TechDraw.

Code: Select all

'''
Coincide two TechDraw views
Workflow:
- Select one vertex in first view
- Select one vertex in second view
- Start the script 
'''
sel0 = Gui.Selection.getSelectionEx()[0] 
vetrex0Name = sel0.SubElementNames[0]
view0  = sel0.Object
pnt0 = view0.getVertexBySelection(vetrex0Name).Point
scale0 = view0.Scale

sel1 = Gui.Selection.getSelectionEx()[1] 
vetrex1Name = sel1.SubElementNames[0]
view1  = sel1.Object
pnt1 = view1.getVertexBySelection(vetrex1Name).Point
scale1 = view1.Scale

c0 = FreeCAD.Vector(view0.X,view0.Y,0) # view0 center on page
p0 = c0+pnt0*scale0 # base point of view 0 on page
c1 = FreeCAD.Vector(view1.X,view1.Y,0) # view1 center on page
p1 = c1+pnt1*scale1 # base point of view 1 on page
delta = p1.sub(p0) # the moving vector

view1.X = view1.X.Value-delta.x
view1.Y = view1.Y.Value-delta.y
User avatar
proghettolab
Posts: 52
Joined: Sat Jun 27, 2020 3:09 pm

Re: [Feature Request] Add a way to align section views to regular views

Post by proghettolab »

Wonderful !!! Thank you!
I need to learn FreeCAD scripting and macros ...

edi wrote: Sun Nov 27, 2022 8:45 am A short script to coincide two points of two different views in TechDraw.

Code: Select all

'''
Coincide two TechDraw views
Workflow:
- Select one vertex in first view
- Select one vertex in second view
- Start the script 
'''
sel0 = Gui.Selection.getSelectionEx()[0] 
vetrex0Name = sel0.SubElementNames[0]
view0  = sel0.Object
pnt0 = view0.getVertexBySelection(vetrex0Name).Point
scale0 = view0.Scale

sel1 = Gui.Selection.getSelectionEx()[1] 
vetrex1Name = sel1.SubElementNames[0]
view1  = sel1.Object
pnt1 = view1.getVertexBySelection(vetrex1Name).Point
scale1 = view1.Scale

c0 = FreeCAD.Vector(view0.X,view0.Y,0) # view0 center on page
p0 = c0+pnt0*scale0 # base point of view 0 on page
c1 = FreeCAD.Vector(view1.X,view1.Y,0) # view1 center on page
p1 = c1+pnt1*scale1 # base point of view 1 on page
delta = p1.sub(p0) # the moving vector

view1.X = view1.X.Value-delta.x
view1.Y = view1.Y.Value-delta.y
User avatar
NewJoker
Veteran
Posts: 3079
Joined: Sun Oct 11, 2020 7:49 pm

Re: [Feature Request] Add a way to align section views to regular views

Post by NewJoker »

@edi Would you be able to implement this macro as a built-in feature ? I think that it could be very useful. Manual view alignment is quite tedious.
edi
Posts: 482
Joined: Fri Jan 17, 2020 1:32 pm

Re: [Feature Request] Add a way to align section views to regular views

Post by edi »

Find a reworked version of the PositionSectionView tool in the next weekly release.

The tool has been extended by the possibility to align inclined section views and section views which have a different height/width than the source view.

Explanation see in Wiki, Usage 2: https://wiki.freecad.org/TechDraw_Exten ... ectionView

An example how to align a section view having a different width than the source view:
SectionViewAA.gif
SectionViewAA.gif (613.73 KiB) Viewed 1079 times
An example how to align an inclined section view:
SectionViewCC.gif
SectionViewCC.gif (520.93 KiB) Viewed 1079 times
Thanks to all who helped, merged and tested the tool.
User avatar
NewJoker
Veteran
Posts: 3079
Joined: Sun Oct 11, 2020 7:49 pm

Re: [Feature Request] Add a way to align section views to regular views

Post by NewJoker »

edi wrote: Fri Dec 22, 2023 10:55 am Find a reworked version of the PositionSectionView tool in the next weekly release.
Thank you very much for implementing this. It's super useful.
Post Reply