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:
- after:
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.
Tested, and it is extremely nice. I would love having it added by default as an Extension Tool.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.
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
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