Draft WorkingPlaneProxy: Difference between revisions

From FreeCAD Documentation
(Vertical GuiCommand)
m (Linted templates)
(24 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>
<!--T:19-->
{{Docnav
|[[Draft AutoGroup|AutoGroup]]
|[[Draft_AddConstruction|Add to Construction group]]
|[[Draft_Module|Draft]]
|IconL=Draft_AutoGroup.svg
|IconC=Workbench_Draft.svg
|IconR=Draft_AddConstruction.png
}}


<!--T:1-->
<!--T:1-->
Line 9: Line 18:
|SeeAlso=[[Draft SelectPlane]]
|SeeAlso=[[Draft SelectPlane]]
}}
}}

==Description== <!--T:2-->
This command will place a Plane Proxy object aligned to the current [[Draft SelectPlane|Working Plane]].

<!--T:9-->
This proxy object can be used like a face to quickly change the working plane using the [[Draft SelectPlane]] tool. The camera position and visibility of the objects in the 3D view can be saved in the proxy object, and restored at anytime when the [[Draft SelectPlane]] tool is used.


</translate>
</translate>
[[Image:Draft WPProxy example.png|400px]]
[[Image:Draft WPProxy example.png|400px]]
<translate>
<translate>
==Description== <!--T:2-->
<!--T:10-->
{{Caption|Three working plane proxies showing different orientations and offsets}}
This command will place a Proxy object in the document, placed and aligned to the current [[Draft SelectPlane|Working Plane]]. When using the [[Draft SelectPlane]] command with such a Proxy object selected, or by double-clicking it in the tree view, the working plane will be positioned and aligned back with the proxy object. The camera position and hidden/shown state of objects are also stored in the Proxy object, and can be restored if the corresponding properties are enabled (see below).


==How to use== <!--T:3-->
==Usage== <!--T:3-->
# Make sure the [[Draft SelectPlane|Working Plane]] is set as you want.
# Make sure the [[Draft SelectPlane|Working Plane]] is set as you want.
# Press Draft -> Utilities -> {{KEY|[[Image:Draft SetWorkingPlaneProxy.png|16px]] [[Draft SetWorkingPlaneProxy|Create WP Proxy]]}}
# Then go to the menu {{MenuCommand|Draft → Utilities → [[Image:Draft SetWorkingPlaneProxy.png|16px]] [[Draft SetWorkingPlaneProxy|Create Working Plane Proxy]]}}.


==Options== <!--T:4-->
==Notes== <!--T:11-->
* The working plane stored in the Proxy object can be restored by double-clicking the object in the tree view, or by selecting the Proxy object and using the {{Button|[[Image:Draft SelectPlane.svg|16px]] [[Draft SelectPlane]]}} button.
* WP proxies can be manipulated (moved and rotated) like any other FreeCAD object
* The position of the camera is stored in the Proxy object upon creation. This position can be updated anytime: zoom, pan and rotate the view as you wish, then right-click the Proxy object in the tree view, and select {{Button|[[Image:Draft SelectPlane.svg|16px]] Write camera position}}.
* The size and appearance of the proxy object can be set in the View properties
* The position of the camera is stored in the Proxy object upon creation. That position can be changed anytime by right-clicking the Proxy object, then select the "Write camera position" option to store the current camera position.
* The visibility state of all objects is also stored in the Proxy object upon creation. This state can be updated anytime: set the {{PropertyView|Visibility}} property of the objects to {{TRUE}} or {{FALSE}} as desired, then right-click the Proxy object in the tree view, and select {{Button|[[Image:Draft SelectPlane.svg|16px]] Write objects state}}.
* Plane proxies can be moved and rotated like any other object so that they define the desired working plane. Their visual appearance can also be changed in the [[property editor]].
* The hidden/shown state of all the objects currently in the document is also stored in the Proxy object upon creation. That state can be updated anytime by right-clicking the Proxy object, then select the "Write objects state" option.
* The Working Plane stored in the Proxy object can be restored by double-clicking the Proxy object in the tree view, or by using the [[Draft SelectPlane]] tool with the Proxy object selected.
* If the '''RestoreView''' property is set to True, the camera position will also be restored to the saved position on double-clicking the Proxy object or using [[Draft SelectPlane]]
* If the '''RestoreState''' property is set to True, the objects hidden/shown state will also be restored to the saved position on double-clicking the Proxy object or using [[Draft SelectPlane]]. If new objects have been added to the document after the state was stored in the Proxy object, the visibility of these new objects will be unchanged


==Properties== <!--T:7-->
==Properties== <!--T:7-->


<!--T:8-->
=== Data === <!--T:8-->
* {{PropertyData|Placement}}: Stores the position of this Proxy and the corresponding Working Plane
* {{PropertyData|Placement}}: specifies the position of the proxy object and the corresponding working plane.
* {{PropertyView|Display Size}}: The size of the Proxy object in the 3D view
** {{PropertyData|Position}}: specifies the coordinates of the proxy object.
* {{PropertyView|Arrow Size}}: The size of the arrows on the 3 axes
** {{PropertyData|Angle}}: specifies the rotation angle of the proxy object.
** {{PropertyData|Axis}}: specifies the axis to use for the rotation angle.
* {{PropertyView|Restore View}}: If true, the camera position will be restored on activating (by double-click or [[Draft SelectPlane]]) this object

* {{PropertyView|Restore State}}: If true, the visibility state of all objects in the current document will be restored on activating (by double-click or [[Draft SelectPlane]]) this object
=== View === <!--T:12-->
* {{PropertyView|Display Size}}: specifies both length and width of the proxy object. If the object is created in the tree view but no element is visible in the 3D view, increase this value until it is visible.
* {{PropertyView|Arrow Size}}: specifies the size of the arrows indicating the three axes of the plane proxy.
* {{PropertyView|Restore View}}: if it is {{TRUE}} the camera position will be restored to the saved position when using the proxy with {{Button|[[Image:Draft SelectPlane.svg|16px]] [[Draft SelectPlane]]}} or by double-clicking on it.
* {{PropertyView|Restore State}}: if it is {{TRUE}} the visibility state of all objects will be restored to the saved state when using the proxy with {{Button|[[Image:Draft SelectPlane.svg|16px]] [[Draft SelectPlane]]}} or by double-clicking on it.


==Scripting== <!--T:5-->
==Scripting== <!--T:5-->

Working plane proxy objects can easily be created in scripts and [[macros]]:
<!--T:13-->
{{Emphasis|See also:}} [[Draft API]] and [[FreeCAD Scripting Basics]].

<!--T:14-->
Working plane proxy objects can be used in [[macros]] and from the [[Python]] console by using the following function:
</translate>
{{Code|code=
WPProxy = makeWorkingPlaneProxy(placement)
}}
<translate>
<!--T:15-->
* Creates a {{incode|WPProxy}} object from the given {{incode|placement}} which is a {{incode|FreeCAD.Placement}}.
** A placement is defined by a base point, given by its {{incode|FreeCAD.Vector}}, and a {{incode|FreeCAD.Rotation}}.

<!--T:16-->
The size of the Plane Proxy can be changed by overwriting its {{incode|ViewObject.DisplaySize}} and {{incode|ViewObject.ArrowSize}} attributes, with units in millimeters.

<!--T:17-->
The Plane Proxy has a "Face" object as its {{incode|Shape}} attribute. This face can be used to set the current working plane by calling its {{incode|alignToFace()}} method.


<!--T:6-->
<!--T:6-->
Line 45: Line 81:
</translate>
</translate>
{{Code|code=
{{Code|code=
import FreeCAD,Draft
import FreeCAD, FreeCADGui, Draft

currentWP = FreeCAD.DraftWorkingPlane
currentWP = FreeCAD.DraftWorkingPlane
Draft.makeWorkingPlaneProxy(currentWP.getPlacement())
place = currentWP.getPlacement()

WPProxy = Draft.makeWorkingPlaneProxy(place)
WPProxy.ViewObject.DisplaySize = 3000
WPProxy.ViewObject.ArrowSize = 200

YAxis = FreeCAD.Vector(0, 1, 0)
point2 = FreeCAD.Vector(3000, 0, 0)
place2 = FreeCAD.Placement(point2, FreeCAD.Rotation(YAxis, 90))

WPProxy2 = Draft.makeWorkingPlaneProxy(place2)
WPProxy2.ViewObject.DisplaySize = 3000
WPProxy2.ViewObject.ArrowSize = 200

Axis = FreeCAD.Vector(1, 1, 1)
point3 = FreeCAD.Vector(-3000, 3000, 0)
place3 = FreeCAD.Placement(point3, FreeCAD.Rotation(Axis, 90))

WPProxy3 = Draft.makeWorkingPlaneProxy(place3)
WPProxy3.ViewObject.DisplaySize = 3000
WPProxy3.ViewObject.ArrowSize = 200
FreeCAD.ActiveDocument.recompute()

currentWP.alignToFace(WPProxy3.Shape)
FreeCADGui.Snapper.setGrid()
}}
}}
<translate>


<!--T:18-->
{{Docnav
|[[Draft AutoGroup|AutoGroup]]
|[[Draft_AddConstruction|Add to Construction group]]
|[[Draft_Module|Draft]]
|IconL=Draft_AutoGroup.svg
|IconC=Workbench_Draft.svg
|IconR=Draft_AddConstruction.png
}}

<!--T:20-->
{{Draft Tools navi}}

<!--T:21-->
{{Userdocnavi}}
</translate>
{{clear}}
{{clear}}

Revision as of 00:18, 4 February 2020

Draft SetWorkingPlaneProxy

Menu location
Draft → Utilities → Create WP Proxy
Workbenches
Draft, Arch
Default shortcut
None
Introduced in version
-
See also
Draft SelectPlane

Description

This command will place a Plane Proxy object aligned to the current Working Plane.

This proxy object can be used like a face to quickly change the working plane using the Draft SelectPlane tool. The camera position and visibility of the objects in the 3D view can be saved in the proxy object, and restored at anytime when the Draft SelectPlane tool is used.

Three working plane proxies showing different orientations and offsets

Usage

  1. Make sure the Working Plane is set as you want.
  2. Then go to the menu Draft → Utilities → File:Draft SetWorkingPlaneProxy.png Create Working Plane Proxy.

Notes

  • The working plane stored in the Proxy object can be restored by double-clicking the object in the tree view, or by selecting the Proxy object and using the Draft SelectPlane button.
  • The position of the camera is stored in the Proxy object upon creation. This position can be updated anytime: zoom, pan and rotate the view as you wish, then right-click the Proxy object in the tree view, and select Write camera position.
  • The visibility state of all objects is also stored in the Proxy object upon creation. This state can be updated anytime: set the ViewVisibility property of the objects to true or false as desired, then right-click the Proxy object in the tree view, and select Write objects state.
  • Plane proxies can be moved and rotated like any other object so that they define the desired working plane. Their visual appearance can also be changed in the property editor.

Properties

Data

  • DataPlacement: specifies the position of the proxy object and the corresponding working plane.
    • DataPosition: specifies the coordinates of the proxy object.
    • DataAngle: specifies the rotation angle of the proxy object.
    • DataAxis: specifies the axis to use for the rotation angle.

View

  • ViewDisplay Size: specifies both length and width of the proxy object. If the object is created in the tree view but no element is visible in the 3D view, increase this value until it is visible.
  • ViewArrow Size: specifies the size of the arrows indicating the three axes of the plane proxy.
  • ViewRestore View: if it is true the camera position will be restored to the saved position when using the proxy with Draft SelectPlane or by double-clicking on it.
  • ViewRestore State: if it is true the visibility state of all objects will be restored to the saved state when using the proxy with Draft SelectPlane or by double-clicking on it.

Scripting

See also: Draft API and FreeCAD Scripting Basics.

Working plane proxy objects can be used in macros and from the Python console by using the following function:

WPProxy = makeWorkingPlaneProxy(placement)
  • Creates a WPProxy object from the given placement which is a FreeCAD.Placement.
    • A placement is defined by a base point, given by its FreeCAD.Vector, and a FreeCAD.Rotation.

The size of the Plane Proxy can be changed by overwriting its ViewObject.DisplaySize and ViewObject.ArrowSize attributes, with units in millimeters.

The Plane Proxy has a "Face" object as its Shape attribute. This face can be used to set the current working plane by calling its alignToFace() method.

Example:

import FreeCAD, FreeCADGui, Draft

currentWP = FreeCAD.DraftWorkingPlane
place = currentWP.getPlacement()

WPProxy = Draft.makeWorkingPlaneProxy(place)
WPProxy.ViewObject.DisplaySize = 3000
WPProxy.ViewObject.ArrowSize = 200

YAxis = FreeCAD.Vector(0, 1, 0)
point2 = FreeCAD.Vector(3000, 0, 0)
place2 = FreeCAD.Placement(point2, FreeCAD.Rotation(YAxis, 90))

WPProxy2 = Draft.makeWorkingPlaneProxy(place2)
WPProxy2.ViewObject.DisplaySize = 3000
WPProxy2.ViewObject.ArrowSize = 200

Axis = FreeCAD.Vector(1, 1, 1)
point3 = FreeCAD.Vector(-3000, 3000, 0)
place3 = FreeCAD.Placement(point3, FreeCAD.Rotation(Axis, 90))

WPProxy3 = Draft.makeWorkingPlaneProxy(place3)
WPProxy3.ViewObject.DisplaySize = 3000
WPProxy3.ViewObject.ArrowSize = 200
FreeCAD.ActiveDocument.recompute()

currentWP.alignToFace(WPProxy3.Shape)
FreeCADGui.Snapper.setGrid()