Macro Wiring And Hoses/pl

'Od User:Piffpoof Uwaga: pewne zmiany pomiędzy v 0.14 a v 0.15 wpłynęły na to makro, co opóźni jego wydanie

Makra te wspierają tworzenie i obsługę sieci przewodów i rur.



Kontekst
Jako część naszych innych projektów FreeCAD potrzebowaliśmy sposobu na udokumentowanie okablowania i rur. Ten zestaw makr został stworzony aby sprostać tej potrzebie. Jest wiele rzeczy, których ten system nie robi, ale to co robi, to zapewnia wizualną reprezentację przewodów i rur, albo jako odizolowany system, albo z przewodami i rurami w kontekście modelu FreeCAD. Zapis wszystkich przewodów i rur jest przechowywany w pliku w formacie CSV poza programem FreeCAD. Plik ten może więc zostać wczytany do programu arkusza kalkulacyjnego lub wykorzystany przez inne oprogramowanie.

Opis
W ramach projektu dokumentacji odkryliśmy, że potrzebujemy udokumentować przewody i rury. Wypróbowaliśmy kilka różnych scenariuszy takich jak tworzenie linii lub cylindrów jako część istniejącego modelu. Ze względu na problemy z ich używaniem lub utrzymaniem zdecydowaliśmy się zachować te informacje w innym formacie i poza programem FreeCAD. W ten sposób mogły być one tworzone samodzielnie lub w ramach istniejącego dokumentu. Ta decyzja pozwoliła użytkownikowi pracować z okablowaniem i rurami w sposób, który mu odpowiadał. Mógł również pracować z nimi na różne sposoby w różnych momentach, gdy zmieniały się potrzeby.

We initially weren't sure how to maintain a list of the hoses and wires and various different approaches were tried. The easiest way seemed to be to use the CSV file format which has been around for a long time. Also there were routines already written for managing CSV files from Python. Some of the advantages were:


 * human readable
 * can be loaded into any spreadsheet
 * can be maintained using a spreadsheet or simple text editor
 * a possible future enhancement would be to use it with the FreeCAD spreadsheet workbench

The next decisions were "how" to define such cables runs. As our purpose was primarily documentation, we chose to run line segments from point to point. Issues such as turn radius are not dealt with. Also cable diameter is not handled. A table of the cable runs is maintained through the CSV file but such things as proximity of cables (for electrical interference issues) and run length are not supported (although it might be possible to add a rudimentary cable run length quite easliy).

This set of macros is essentially a "proof of concept", it demonstrates some ideas and their feasibility. Our main goal was documentation, not physical plant management.We decided to maintain a data structure of points, which are the points through which the wires and hoses run. Secondly we set up a data structure which defines the cables and hoses in terms of the points they pass through. So a wire may only be routed where points for it have been defined.

For the 2 data structures we chose the following names:
 * Nexus - a point through which a cable or hose may pass (the plural is Nexi). Nexi are simply points in 3-space, for ease of visualisation the software places toroid rings around the location but this is only for ease of use. The toroid rings can be toggled off or on depending on user preference
 * Flows - generically these are routes comprised of Nexi. A code is associated with each type, the default codes being
 * W - electrical wires
 * C - conduits, intended primarily for wires but able to contain anything
 * H - hoses to carry a variety of liquids
 * G - gas lines
 * K - a camera routing, this is really just reserved for future exploration as per Tour camera animation

Both Nexi and Flows have user assigned names, in addition Nexi have internally assigned IDs to facilitate management. Being points or locations in 3-space Nexi do not have colours but Flows can have one of 48 defined colours. The emphasis on colours ties back to the intended purpose being one of documentation.

The general workflow is
 * define and position Nexi
 * define Flow(s) in term of Nexi
 * for maintenance purposes edit both Nexi and Flows either visually using the FreeCAD GUI or using a tabular approach and the CSV definitions

As the data file which holds both the Nexi and Flow definition is text based it can be used in any text editor or by any other program wishing to access the data.

Navigation Modes
As a large part of the work with these macros depends on manipulating the display of the model to place and verify the placement of point in 3-space, it is essential to be comfortable with the Navigational Modes of FreeCAD which are documented on the page Mouse navigation. Being able to rotate the model in 3-space and then perform operations on a stationary model are essential.

Installation
The code for Wiring And Hoses is in multiple macros and a library. So installation is comprised of copying the code to the appropriate Macro directory and invoking the Build Utility from the Macro menu, the Python console or a toolbar button (the preferred method).


 * see How to install macros for information on how to install this macro code
 * see Customize Toolbars for information how to install as a button on a toolbar

Usage
There are really two different approaches to working with these macros: the nexi and flows can be defined on their own using 3-space coordinates; or an existing FreeCAD document can be used and the nexi and flows can be defined in the context of that document. This is not an 'either/or' decision but rather both approaches can be used when they are the most appropriate. As the definitions of the nexi and flows are kept in a CSV format file which is stored outside of FreeCAD, the presence or absence of a FreeCAD document does not affect working with the nexi and flow, it makes it easier by providing a visual context. For this description of usage the example will use a previously loaded FreeCAD document as a context as it is easier to place the

The usage of these macros really breaks down into 3 sections:
 * define nexi
 * define flows
 * edit the CSV format file to alter or add nexi and flows

There are alternative ways to perform some of the tasks outlined below and personal preference can decide. This example will apply electrical wiring and cold water plumbing to a house. Our empty house looks like this



and is waiting for cold water and electricity to be installed. For convenience of explanation all the electrical items are in yellow and the water in blue (aside from the 2 sinks).

Define Nexi
The first step is one of creating points in 3-space (called 'nexi' or 'nexus" in the plural). These points will be used in the next step to define a flow. We create these points by clicking on (i.e. selecting) a surface and then supplying a name for the nexi. This description is of defining the nexi for the water flow.

 This is asking if you would like to open and load a FreeCAD document which has the model which you wish to add nexi and flows to. It is not necessary to load one but for this example we will load our empty house
 * 1) click on 
 * 2) the following dialog will appear:

 
 * 1) select a surface by clicking on it, it will be highlighted in the Tree window and have a colour indicating selected in the display.
 * 2) click on 
 * 3) the following dialog will appear asking for a name for the new nexi:
 * 1) the nexi will now be defined. It will be positioned in 3-space so that it is on the line from the selected face to the viewer, positioned just off the face so that it is not inside the object. Although the nexus might not be in the perfect position, leave it for the moment as it will be edited in a later step. A toroid (i.e. ring) will be displayed, it is centred on the point of the nexus. This ring is purely a visualisation tool so the location of the point can be  identified. The visualisation rings can be toggled on/off at any time.
 * 2) define any more nexi in the same fashion, giving each a meaningful name
 * 3) click on 
 * 4) the following dialog will appear:
 * 1) answer Yes to save your new nexi

Note : at any point you can merge an existing project so as to have a visual context

Define Flow
Once nexi have been defined they can be used to define a flow. Our house now looks like this:

< picture of house with nexi but not flows>

It has nexi defined for the water flow but now flows as of yet.

the following dialog will appear:
 * 1) click on 



This is asking if you to select the nexi in the order you want them to create your flow.
 * 1) select the type of Flow: Wires, Conduits, Hoses, Gas Lines
 * 2) using the second popup, select the nexi in the order you want them




 * 1) supply a name for the flow
 * 2) select a colour for the flow
 * 3) click OK or Cancel. If you make an error in selecting the nexi (either order or including a wrong nexi) then click Cancel and restart this step.

< picture of house with water flow>



Editing Nexi and Flows
There are 3 different ways to edit nexi. As the flows are defined in terms of nexi, altering nexi will affect any flow which includes them. For the descriptive flow attributes like colour and name, there is one way to make edits.

So far in this example we have generated the following table:







User Interface
The user interface is a combination of custom screens along with standard parts of the FreeCAD GUI.







Opcje
W chwili obecnej nie ma żadnych opcji dotyczących przewodów i rur.