GuiCommand: Name: Std LinkMake MenuLocation: None Workbenches: All Version: 0.19 SeeAlso: Std_Part, Std_Group, PartDesign_Body
Sandbox:Roy 043
Description
The Std LinkMake command creates App Links (App::Link
class). An App Link, or Link for short, is an object that references, links, to another object in the same document, or in another document. It is especially designed to efficiently duplicate a single object multiple times and forms the basis of the Assembly3 Workbench and the Assembly4 Workbench.
A Link object can optionally behave like an array by duplicating its base object several times. This Link Array object can also be created with the different array tools of the Draft Workbench.
The Std LinkMake command is not defined by a particular workbench, but by the base system, thus it is found in the structure toolbar that is available in all workbenches.
Usage
Same document
- Select one or more objects.
- There are several ways to invoke the command:
- For each selected object a Link is created.
External document
- If required change the Tree view DocumentMode to MultiDocument with the Std TreeMultiDocument command.
- Open a source document and a target document.
- Select one or more objects in the source document.
- Switch to the target document by clicking its tab in the Main view area.
- Press the Make link button.
- For each selected object a Link is created.
Start with empty Link
- Make sure no object is selected.
- There are several ways to invoke the command:
- An empty Link is created.
- In the Property editor click in the Linked Object field of the Link.
- Press the ... button.
- The Link dialog opens.
- Do one of the following:
- Select an object from the same document.
- Switch to an external document by clicking its tab in the Main view area, and select an object there.
- In both cases you can also select a subelement from an object in the 3D view. This will create a Sub-Link. See Std LinkMakeRelative.
- Press the OK button.
(1) An object, (2) an empty Link, (3) a full Link to the first object (with overridden material), and (4) a Link to only some subelements of the object. The empty Link is not tied to a real object so it is not displayed in the 3D view.
(1, 2) Two objects from a source document linked into a target document, (3) a Link to the second Link (its tab in the Main view area), and (4) a Link to the subelements of the second Link.
Drag and drop
You can also create Links by performing a drag and drop operation in the Tree view.
- Select one or more objects in the Tree view.
- Hold down the Alt key.
- Drag the selection to the document label of the current document or an external document.
- The cursor icon will change.
- Drop the selection.
Notes
- When linking to an object in an external document both the source document and the target document have to be saved at least once. This is required to determine the relative path for the Link.
Link Array
A Link can be turned into an array where each element has its own placement and appearance.
- Make sure the Show Element property of the Link is set to
True
(this is the default). - Change the Element Count of the Link to {{Value|1}} or more. Using {{Value|1}} results in an array with a single element, so you will typically use a value of {{Value|2}} or more.
- Each Link element in the array can be positioned individually by changing its own Placement property.
- In a similar way, each element in the array can have its own appearance. See Override appearance below.
- Once you are satisfied with the placement and properties of the Link elements in the array, you can change Show Element to
False
in order to hide them in the Tree view.
<img alt="" src=https://raw.githubusercontent.com/FreeCAD/FreeCAD-documentation/master/wiki/images/Std_Link_tree_array_example.png ) ![](https://raw.githubusercontent.com/FreeCAD/FreeCAD-documentation/master/wiki/images/Std_Link_array_example.png style="width:500px;">
(1) Original object, and (2, 3, 4) a Link array with three elements, each in a different position. The first Link has an overridden material and transparent faces, the other two have custom face colors.
Notes
- When creating this type of Link Array, you must place each of the elements manually. If you need a patterned array you should use the array tools of the Draft Workbench, like Draft OrthoArray, Draft PolarArray, and Draft CircularArray. These commands can create normal copies or Link copies depending on the options at creation time.
Link to Std Part
[Std LinkMake](wiki-test2.php?gitpage=Std_LinkMake) can be used on [Std Parts](wiki-test2.php?gitpage=Std_Part) in order to quickly duplicate groups of objects, [assemblies](wiki-test2.php?gitpage=assembly), positioned in space. A Link to a Part will keep the visibility of its child objects synchronized with that Part. If you hide a child object in the Link, it will be hidden in the original Part, as well as in all other Links to that Part.Link to Std Group
A regular Std Group does not have a Placement property, so it cannot control the position of its child objects. However when Std LinkMake is used on a Std Group the resulting Link does have a Placement and, like a Std Part, can control the position of its child objects. A Link to a Group allows independent control of the visibility of its child objects.
Link to PartDesign Body
A Link can be created from a PartDesign Body, but not from its individual features. To avoid selecting them instead of the Body, it is recommended to set the Display Mode Body property to {{Value|Tip}}.
Link to Link
Override appearance
By default a Link has the same appearance as the original Linked Object. There are two options, which can be combined, to override that.
Override material
If the Override Material property of a Link is set to True
, its Shape Material property will control its appearance. Note that if the Override Material property of a Link Array is set to True
, the individual Override Material properties of its elements are ignored.
Override colors
It is possible to change the appearance of individual subelements (vertices, edges and faces) of a Link. Sublements can also be child objects inside Links to Parts and Groups, and elements in a Link Array. Apart from changing their appearance, subelements can also be hidden.
- Select a Link in the Tree view.
- Right-click and select the Override colors... option from the context menu.
- The Set element color task panel opens.
- Pick one or more subelements in the 3D view.
- Do one of the following:
- To change the appearance of the subelements:
- Press the Edit button.
- Specify the color and transparency in the Select Color dialog.
- The subelements receive the selected color and transparency, and are added to the list with a color swatch.
- To hide the subelements:
- Press the Hide button.
- The subelements are hidden in the 3D view and are added to the list with an eye icon .
- When the cursor is over a hidden subelement in the list, it is temporarily made visible in the 3D view.
- To change the appearance of the subelements:
- To remove custom attributes:
- Select one or more elements in the list.
- Press the Remove button.
- Optionally press the Remove all button to remove all custom attributes from the Link.
- Press the OK button to close task panel.
A Std Part containing three objects, and a Link to that Part. In the Link, (1) the first object is made invisible, (2) the second object has some subelements with different colors, (3) the entire third object has a different color and a level of transparency.
Notes
- The coloring of subelements is subject to the topological naming problem so it should be done as the last modelling step, when the model is no longer subject to change.
- The individual elements in a Link Array are listed in the Tree view if Show Element is
True
and can then be shown or hidden by pressing the Space bar. This generally makes more sense than using the Override colors... option to control their visibility. - If the Alpha channel option is missing in the Select Color dialog then add this Boolean preference: Tools → Edit parameters... → BaseApp → Preferences → Dialog → DontUseNativeColorDialog, and set it to
False
. See Std DlgParameter and Fine-tuning for more information.
Properties
The App Link (App::Link
class) is derived from the basic App DocumentObject (App::DocumentObject
class) and inherits all its properties.
The following are the specific properties available in the Property editor. The App Link will additionally show the properties of the original Linked Object. The names of these linked properties appear in green in the Property editor. Hidden properties can be shown by using the Show all command in the context menu of the Property editor.
Data
{{TitleProperty| Link}}
-
Linked Object|XLink: it indicates the source object of the App Link; this can be an entire object, or a subelement of it (vertex, edge, or face).
-
Link Transform|Bool: it defaults to
False
, in which case the Link will override the Linked Object\'s own placement. If it is set toTrue
, the Link will be placed in the same position as the Linked Object, and its placement will be relative to the Linked Object\'s placement. This can also be achieved with [ Std LinkMakeRelative. -
Link Placement|Placement|Hidden: it is an offset applied on top of the Placement of the Linked Object. This property is normally hidden but appears if Link Transform is set to
True
; in this case, Placement now becomes hidden. -
Placement|Placement: the placement of the Link in absolute coordinates.
-
Show Element|Bool: it defaults to
True
, in which case the Tree view will show the individual Link copies, as long as Element Count is {{Value|1}} or larger. -
Element Count|IntegerConstraint: it defaults to {{Value|0}}. If it is {{Value|1}} or larger, the App Link will behave like an array, and will duplicate the same Linked Object many times. If Show Elements is
True
, each element in the array will be displayed in the Tree view, and each can have its own Placement modified. Each Link copy will have a name based on the Link\'s Name, augmented by_iN
, whereN
is a number starting from0
. For example, with a singleLink
, the copies will be namedLink_i0
,Link_i1
,Link_i2
, etc. -
Link Execute|String: name of the execute function that will run for this particular Link object. It defaults to {{Value|'appLinkExecute'}}. Set it to {{Value|'None'}} to disable it.
-
Colored Elements|LinkSubHidden|Hidden: list of Link elements that have had their color overriden.
-
Link Copy On Change|Enumeration: {{Value|Disabled}} or {{Value|Enabled}}.
-
Scale|Float: it defaults to {{Value|1.0}}. It is a factor for uniform scaling in each direction
X
,Y
, andZ
. For example, a cube of {{Value|2 mm}} x {{Value|2 mm}} x {{Value|2 mm}}, that is scaled by {{Value|2.0}}, will result in a shape with dimensions {{Value|4 mm}} x {{Value|4 mm}} x {{Value|4 mm}}. -
Scale Vector|Vector|Hidden: the scale factor for each component
(X, Y, Z)
for all Link elements when Element Count is {{Value|1}} or larger. If Scale is other than {{Value|1.0}}, this same value will be used in the three components. -
Scale List|VectorList: the scale factor for each Link element.
-
Visibility List|BoolList|Hidden: {{emphasis|(read-only)}} the visibility state of each Link element, either
True
orFalse
. -
Placement List|PlacementList|Hidden: {{emphasis|(read-only)}} the placement for each Link element.
-
Element List|LinkList|Hidden: the list of Link elements.
-
_ Link Touched|Bool|Hidden:
-
_ Child Cache|LinkList|Hidden:
-
_ Link Owner|Integer|Hidden:
{{TitleProperty|Base}}
- Proxy|PythonObject|Hidden: a custom class associated with this object. This only exists for the Python version. See Scripting.
View
{{TitleProperty| Link}}
-
Draw Style|Enumeration: it defaults to {{Value|None}}; it can be {{value|Solid}}, {{value|Dashed}}, {{value|Dotted}}; defines the style of the edges in the 3D view.
-
Line Width|FloatConstraint: a float that determines the width in pixels of the edges in the 3D view. It defaults to {{value|2.0}}.
-
Override Material|Bool: it defaults to
False
; if set toTrue
it will override the Linked Object\'s material, and it will display the colors defined in Shape Material. -
Point Size|FloatConstraint: similar to Line Width, defines the size of the vertices.
-
Selectable|Bool: if it is
True
, the object can be picked with the pointer in the 3D view. Otherwise, the object cannot be selected until this option is set toTrue
. -
Shape Material|Material: this property includes sub-properties that describe the appearance of the object.
-
Diffuse Color
, it defaults to light blue .
-
**Ambient Color**
, it defaults to dark gray .
-
**Specular Color**
, it defaults to black .
-
**Emissive Color**
, it defaults to black .
-
**Shininess**
, it defaults to {{Value|0.2}}
-
**Transparency**
, it defaults to {{Value|0.0}}.
{{TitleProperty|Base}}
-
Child View Provider|PersistentObject|Hidden:
-
Material List|MaterialList|Hidden: (read-only) if individual materials have been added, they will be listed here.
-
Override Color List|ColorList|Hidden: (read-only) if the individual faces or edges of the link have been overridden they will be listed here.
-
Override Material List|BoolList|Hidden: (read-only) if the individual materials of the link have been overridden they will be listed here.
-
Proxy|PythonObject|hidden: a custom viewprovider class associated with this object. This only exists for the Python version. See Scripting.
{{TitleProperty|Display Options}}
-
Display Mode|Enumeration|Hidden: {{Value|Link}} or {{Value|ChildView}}.
-
Show In Tree|Bool: see the information in App FeaturePython.
-
Visibility|Bool: see the information in App FeaturePython.
{{TitleProperty|Selection}}
-
On Top When Selected|Enumeration: see the information in App FeaturePython.
-
Selection Style|Enumeration: see the information in App FeaturePython.
Scripting
See also:
FreeCAD Scripting Basics and scripted objects.
See Part Feature for the general information on adding objects to the document.
An App Link is created with the addObject()
method of the document. its Linked Object can be defined by changing its LinkedObject
property, or by using its setLink
method.
import FreeCAD as App
doc = App.newDocument()
obj1 = App.ActiveDocument.addObject("Part::Box", "Box")
obj2 = App.ActiveDocument.addObject("Part::Cylinder", "Cylinder")
obj1.Placement.Base = App.Vector(10, 0, 0)
obj2.Placement.Base = App.Vector(0, 10, 0)
link1 = App.ActiveDocument.addObject("App::Link", "Link")
link2 = App.ActiveDocument.addObject("App::Link", "Link")
link1.LinkedObject = obj1
link2.setLink(obj2)
link1.Placement.Base = App.Vector(-10, -10, 0)
link2.Placement.Base = App.Vector(10, -10, 0)
link1.ViewObject.OverrideMaterial = True
App.ActiveDocument.recompute()
The basic App::Link
doesn\'t have a Proxy object so it can\'t be fully used for sub-classing.
For Python subclassing you should create a App::LinkPython
object.
import FreeCAD as App
doc = App.newDocument()
obj = App.ActiveDocument.addObject("App::LinkPython", "Link")
obj.Label = "Custom label"
{{Std Base navi}}
⏵ documentation index > Sandbox:Roy 043
This page is retrieved from https://github.com/FreeCAD/FreeCAD-documentation/blob/main/wiki/Sandbox_Roy_043.md