OS: Windows 10 (10.0) Word size of OS: 64-bit Word size of FreeCAD: 64-bit Version: 0.19.17089 +1543 (Git) Build type: Release Branch: LinkStage3 Hash: 950c082111ae5ebeefb4dddc90a80dc9b54b2408 Python version: 3.6.8 Qt version: 5.12.1 Coin version: 4.0.0a OCC version: 7.3.0 Locale: English/United States (en_US)
In this section we will develop concepts to organize re-usable (standard) components in respositories. We already used a local repository inside the project file and links in the design to reference respository components. In these tutorials we will move standard components to an external repository. Such a respository can be shared among projects. This tutorial borders, and how components can be organized in repositories.
We will demonstrate how Assembly 3 Links work across files, and how to repair broken links.
In this tutorial we will see how to move components from a project file repository in figure 25 to an external repository in figure 28.
With drag & drop techniques, this should be a no-brainer. Unfortunately, the current version of Assembly 3 is not quite finished, and we will end up with broken links. This tutorial shows how to recover from such a situation.
Here are the components used in the project. The first three are standard components, washer, nut and screw. These are likely to be re-used in other projects, so it might be a good idea to store them in a separate file.
We will start with the washer component Assembly000 000, and move it to the new repository file.
It appears that the current version of the Assembly 3 build is not yet quite finished in this area. So we will have to manually carry out the missing steps.
As mentioned above, the Linked Object property is empty. Fortunately, the Label value still gives a hint to what object we have to look for: Assembly000 000. This is a benefit of the strange naming convention I used for Links.
The link dialog window shows all model nodes of a file in a simple list.
The washers on the underside of the block re-appeared in the 3D window, but the node still has this error icon.
The error icon disappeared, the node is OK now.
The washers on the upperside should have reappeared.
To check whether there are still hidden errors in the project file you can…
If nothing unfolds, the file is OK.
Now move the hex nut component:
The hex nut component should be in the external repository now.
You can drag multiple nodes at once to the repository, but be careful not the screw up the link source fields with the wrong values.
The cylinder head screw will make problems. That is one of the reasons we saved the file before every transaction.
Note that not only the Assembly node was moved, but also some additional nodes: XY_Plane003 and Pad005, and Sketch006.
This indicates to an experienced user that Assembly002 000 has dependencies in the additional nodes. It is not quite easy to find them, but Pad005 in the 3D window looks like our Block component:
The following recipe shows a method to find the element(s) that causes problems:
The tree unfolds and exposes a node with an error icon, Pad003
The Length property deserves your attention: The value is a formula, and the expression references Pad005.Length. This is the thickness of our Block component! The thickness determines the lenght of the thread.
It appears that the screw is not really a standard component…
We have now three choices:
I have seen Undo to fail in this context, at least in the current version of Assembly 3, so reverting to the last stored file version seems to be the better option.
The third option will be chosen in the next tutorial, so we'll go for the second option, revert the files.
Cleanup:
The steps to repair the broken links are relatively simple. The specific naming convention helps to identify the missing link source object.
An interesting concept to work with standard components is to use Links to a Link that links to a component:
The component may be stored in the local repository in the project file initially. When matured, the component can be moved to an external repository:
When used early in the project, this concept can save a lot of work. And as an added bonus, it is quite easy to work with variants:
Only the local repository link has to be modified to point to the new component, all dependent links will inherit the change automatically.
This additional link layer can be created easily with the Assembly 3 Replace With Link function.
Note that you must save an external repository file before a link into the file can be created, because the file name is part of the link information.
Now we will replace the first repository component with a Link:
The component in the repository has been replaced by the link node Assembly000 003, and the component has moved down near the end of the model tree.
Everything looks fine, but…
The model tree unfolds and reveals three nodes with problems:
Fortunately, we already know how to deal with that:
That repaired the link to the external component.
The remaining two problem nodes are treated similarly, except that their link source object Assembly000 003 is found in the local repository:
Note that new objects always seem to appear at the end of the list, so you don't always have to set a search filter.
To verify that there are no more problems with the file, …
If the project file is OK, no new problem nodes are unfolded.
As we have learned from the previous exercise, the cylinder head screw Assembly002 000 causes problems because of a reference to Pad005.Length in the Pad003.Length value.
Now the component is prepared to be moved to the external repository
Final cleanup:
As we have seen in this example, the function Replace With Link creates an indirection layer for a component. Now the component can be moved, or even exchanged with a different component. This will be explored in the next example.
Assembly 3 Link objects make it easy to replace one component with another in the entire project, without breaking the project model. The only requirement is that both components, old and new, have the same public constraint connector names.
In this example, we will replace the cylinder head screw with a hexagon head screw.
We will create a new compontent in the external repository, and modify the link in the local repository to point to the new component.
Step 1: Load the initial state files, and rename them to obtain the work files.
We will now create a second screw in the respository file.
Wrap the new Body with an Assembly object:
Create the constraint connector:
To make the new screw compatible with the old one, the public constraint connectors must have the same label name:
The connector in the 3D window:
Obviously, it is possible to have duplicate Element label names!
NOTE that the internal name of the node ("Element005") now differs from the label value ("Element004"). Make sure that this is not a source of confusion!
Final cleanup steps:
The repository is ready. Now we can exchange the screw in the project file.
Why not copy the cylinder head screw?
In the current preview version of Assembly 3, the copy function is not always reliable, and sometimes produces access violations, sometimes the copy dialog looks different. It is not clear whether the model structure is damaged, or not, so we will opt for the safe road.
Now we will verify that the constraints in the project are still operational.
Now the fasteners should have moved:
Instead of directly linking to repository components, an additional link layer in the local project repository opens an option to exchange components with other, compatible versions. To help migrating components, the Replace with link function was used. However, the the function is not yet perfect, some manual actions have to be carried out to fix broken links in the project.
Repository files should never be renamed or moved. Such an operation breaks existing projects that depend on shared libraries. Unfortunately, reality is different. Servers go out of service, storage structures will be reorganized, project move to different computers.
The following tutorial deals with such a situation.
Fortunately, the Linked Object propety now carries a detailed error message:
So we can search for the repository file, and load it manually:
Now we can reassign the broken Linked Object fields. The error info specifies the name of the linked object, but this is the internal name, not the searchable Label value. Fortunately, our naming convention gives the hint to name to search for.
The missing washer component re-appears in the 3D window.
All broken links should have been repaired now.
Situations like these are another strong argument for an external components link layer in the local repository of a project file. This limits the number of broken links to the number of different components used from the repository.
If you linked directly to external components throughout the entire project file (the "quick & dirty" method...), the number of broken links would equal the total number of links to external components (in that repository).
If you open a project that contains links to an external repository, the repository is also opened, but only the linked parts are loaded into memory. This space-saver allows you to work with very large libraries with a lot of "unused" parts inside, without having to worry about memory constraints.
If you explicitly open the repository, the entire library is loaded into memory. This allows to add links to other parts in the repository to the project.
If you close a repository file, the linked parts disappear from the 3D view. If you re-open the repository, the parts reappear.
If you open a different repository with the same parts but different implementations, these alternative parts appear in the project. This allows you to swap one repository file for another with different part implementations. The only requirement is that the internal names and the Connector names of objects are the identical in both repositories.
In this section we will explore the recommended workflow with external repositories, and the effect of the object naming convention.
As always, we begin with setting up the work files.
Have a look at the component names (the Label property) in the repository.
I used a key string that identifes the component and its main characteristics: A washer, a hex nut and a cylinder head screw. The composition of such a key string is usually company-specific, but there should be rules for naming standard components.
The other rule I recommend to follow here is the postfix " 000": This stands for the definition of a component.
The description string (in the Label2 property) was left empty, you can add additional information here that might be useful for selecting a component. Note that this information is not usually copied when a Link is created from a component definition.
In a project file, the Description should contain information about the purpose of a component in the design.
In the next step we will create links to some of the components and import them into the project:
Three component Links are added to the repository file. Now we will move them to the local repository in the project file.
Currently it is not possible to drag the link objects from the repository and drop them directly on the group node.
Note the node names: The instance counter has been incremented to "001". In our naming convention this means that the node is a member of the indirection layer, and not to be used directly in the construction. The next steps demonstrate how to use them in the Project Assembly Container:
Note the instance numbers. A value greater than one indicates a component used in the construction. The workflow implements the scheme illustrated in figure 25:
The following table summarizes this relationship:
Index | Usage |
---|---|
000 | Component Definition |
001 | Link layer in local repository |
002 | Component links used in the project |
… |
The naming scheme offers the following benefits:
Final project file cleanup:
The repository file was not changed, so we don't need to save it.
There are situations where you want to move components from an external repository into the project file, for example to hand out the entire project so someone else in a single file.
This can be done with the Import Link command. The workflow is as follows:
Note that their Label Names have not changed, and even the Description fields were copied from the external repository components.
Note that we now have the component definition (Assembly999 000) and the component indirection layer (Assembly999 009) in the repository. If we