# Usage Questions and Answers

A stated goal of the PythonCAD project is to produce an easy to use CAD package. Still, questions will arise as to how to do some certain operation in PythonCAD. This page will hopefully provide answers to these questions. Keep in mind that the program is in its earliest form, so an answer stating That cannot be done as the code for doing that has not yet been written will be common. Over time, that answer should appear less and less frequently, and some happy day in the future it will not appear at all. If you are able to help develop the code and do so, that day arrives sooner.

### How do I ...

- enter a point/radius/...?
- work with layers?
- print a drawing?
- set the color/linetype/thickness/... of an object?
- change the color/linetype/thickness/... of an object?
- add a new linetype/style/dimstyle?
- set dimension attributes?
- enter commands?

This list is by no means complete, and will be added to as various new question arise.

#### Entering Data

If you are being prompted for a single value of something, like the radius of a circle, just type it in the entry field below the drawing. If you type in the value as an integer value (no decimal point), PythonCAD will convert it to a float value if needed. If it does not do this then you have found a bug. When PythonCAD wants you enter a point in the entry area below the drawing, it will expect you to enter the point in parenthesis, with the x and y coordinates separated by a comma. So, if you wanted to enter a point at the location (0.0,0.0), just type it in like that. You do not need quotes around the parentheses, nor around the digits.

Some effort is made to evaluate what you enter, so if you enter the point like this `((3.4 + 5.5), (2.3 + 3.2))`, PythonCAD will create a point at (8.9, 5.5). Entering any arbitrary expression into will probably not work (yet), though at some point it is hoped that PythonCAD will be able to handle really complex expressions. As Python itself can handle the expressions, the weakness is in the PythonCAD code.

#### Working with Layers

PythonCAD is built around the idea that a drawing is simply a collection of layers with various entities stored in each layer. There is no restriction as to how many layers a drawing may have. All drawings will have at least one layer, and, if you wanted to, you could put all the entities comprising the drawing in that single layer. As drawings get more complex, though, it will probably be clearer if you split up the entities between the layers. One idea could be to place all the dimensions in a layer, the construction lines and circles in another, etc. You will have to decide what works best for your particular needs.

Nearly all the layer operations can be done through the layer display on the side of the drawing. If you right-click a particular layer, a pop-up menu will appear. This menu gives you the choices of renaming the layer, hiding or showing it, and hiding or showing any layers that are children of that layer. Eventually the code will allow you to drag and drop the layers so you can re-parent them as needed. For now the drag and drop functionality only allows you to re-order the layers under a parent. That is, the children layers A-B-C can be reordered to A-C-B.

If you add a new layer, the new layer becomes the active layer. Any entities that are drawn will now be stored in this layer. If you want to change which layer is active, just click on the layer that you want to activate. When a drawing has multiple layers, the entities in the active layer are drawn showing what color they have. Entities kept in the inactive layers are all drawn the same color (currently a blue color). A future release will allow you to choose the color for inactive layers, but for now you have to stick with blue.

If you draw an object in one layer, and then decide you want to move it to another layer, you can do that through the use of the Transfer menu item in the Modify menu. After you invoke the menu item, you can click on the objects that you want to pull into the current active layer. Fillets and chamfers cannot be pulled from one layer to another just yet; this problem should be rectified in an upcoming release.

#### Printing and Plotting

As of the seventeenth release, PythonCAD can now print! The program will generate a PostScript file that can be sent to a printer or saved to a file. The initial printing support has several know flaws, such as not printing the dimension end-point markers like arrows or slashes. Subsequent releases will fix these problems as well as enhance the overall printing abilities of the program.

The strategy for printing support had always been to generate a file in some format that did not depend on the interface, and PostScript has filled that bill nicely. For people not using PostScript printers, there are third party software packages like Ghostscript that can convert the PostScript output into other formats.

#### Setting Object Attributes

The current linetype, color, style, and line thickness are all set from the Set submenu in the Draw menu. Depending on which menu choice you make, a dialog box will appear and allow you to set the value of whatever attribute you wish to change.

#### Changing Object Attributes

The ability to change an objects color, linetype, thickness, or style was added in the second release. First, you must select the objects that you want to change. Use the Select menu item in the Edit menu to select the entities that will get modified. Next, go to the Modify menu, and use one of the choices found in the Change submenu. After clicking OK in whichever dialog box that appears, the selected objects will now have the new attribute values from your menu and dialog choice.

There is currently no easy way to identify which entities are selected, and this deficiency will be rectified in an upcoming release. Also, after changing the attribute of the selected entities, the selected entity list is cleared. This behavior may or may not be a considered a feature, and could change depending on user feedback.

#### Adding new Linetypes/Styles/Dimension Styles

There is no interface code written for doing this yet, so adding one of these things means delving into the code. There should be either a simple dialog box, or a sequence of dialogs, that will make it easy to do this sort of work, but none of that has been written. Also, questions regarding the saving and loading of these customized features will need answers, as the initial release (and probably many following releases) do not have any support for reading what would be a customization or preferences file.

For storing preferences, it is envisioned that there will be a global set of preferences stored in some file, and a user-specific set of preferences kept in each user's directory. If these files are written in Python code, then they could be brought into the program via an `import` statement, or the use of the `imp` module, though the decision as to what these files will be written in, let alone their format, has yet to be made. Feedback to the developers will determine what route to pursue. Other file format options are things like XML or some home-grown key/value text file.

Writing the preference files in Python does seem to present advantages over other formats, as there would be no need to try and write some sort of parser to read the file. Reading the file would be very quick, and any errors could be caught by a simple try/except block. Other alternatives could require more work for the importation of the data in the files. Still, it may be simpler to write the information out in a format other than Python, and that may be a deciding factor on just how to handle this problem.

Update: Storing the preferences as files written in Python has been implemented since the fifth release. This approach has utilized the `imp` module to load the file and, as the preference file is Python code, makes use of the Python interpreter to parse the file. This approach has worked reasonably well, and has provided a good initial implementation of storing and loading user preferences. At present editing the global preference file is done with a text editor, and probably requires root access as the file is hard-coded to reside in the /etc/pythoncad/ directory. A user can copy this file to a $HOME/.pythoncad/ directory and modify it to their own needs. It is planned that in some future revision the file paths will be more adjustable, as well as be more suitable for non-unix platforms.

#### Dimensioning

Dimensions are currently the most complex objects in PythonCAD. Any individual dimension has a large number of attributes that can be set, such as line and font color, dimension text position and formatting, and various properties relating to the dimension lines themselves. Dimensions are also at a very early stage in the code, so for all the things they can do, there are many lines of code still needing to be written in order to exercise all the dimension functionality that exists.

The fourth release of PythonCAD addressed many of the shortcomings in the earlier releases. Angular dimensions can be created, displayed, and saved, and linear dimensions will be displayed (they could be created but wouldn't show up). The display of the dimension text is also improved, and the interactive creation of dimensions now has some visual feedback to indicate the dimension points and text location. There is still much work to be added in making dimensions more flexible and editable, but progress is being made, and the fourth release contains vastly improved dimensioning capabilities.

General dimension properties can be set through the Preferences menu item in the Dimension menu. Ideally, all drawing preferences will be set though a single Preferences menu, and there will not be one in both the Edit and Dimension menus. The reason there are two menus now is that the author did not have a good way to integrate dimensional preferences with the preference dialog that exists in the Edit menu. It is clear that using a notebook widget with lots of pages is not a good user interface design. The current layout for selecting preferences needs to be completely reworked, as the program will gain many more user-definable options in the coming releases. Examples of good preference dialogs would be welcomed, as a clear, concise means of setting preferences will probably borrow ideas from them.

For the initial releases, the easiest way to find out what a dimension can do is poke around the dimension preference dialog, alter some of the settings, then go dimension some objects in a drawing. Be advised that PythonCAD will not add a dimension to a drawing if it is duplicating an existing dimension. For example, if you have a drawing consisting of a single line segment, this drawing can have at most one horizontal dimension, one vertical dimension, and one linear dimension. You cannot draw multiple identical dimensions between two points, as the second, third, fourth, etc. dimension would just be repeating the information given in the first dimension. This behavior is considered a feature, and it will take a number of good reasons for changing this design decision.

#### Commands

The seventh release of PythonCAD shipped with the first iteration of a command interpreter. The long-term goal with the command interpreter is to make it possible to use PythonCAD to a great extent by just typing commands in the entry box at the bottom of the screen. As this functionality is new, it is quite limited in what it can do at the moment. Future releases of PythonCAD will add more commands and enhance the usability of the command interpreter.

Visit this page for a description of the available commands in PythonCAD.