SolidWorks Express
By Bill Fane, Mechanical Engineering Instructor & Consultant
DWGeditor Tips
 
BALANCING YOUR SCALES: Details at Other Scales
DECODING THE DXF FILES: Can You Count to Two?
   
> BALANCING YOUR SCALES: Details at Other Scales
   
>>
The Challenge:
 

Many parts are relatively large but have much smaller details on them, such as a snap-ring groove on a shaft. If we draw the shaft to scale, then the groove is too small to be adequately seen and dimensioned. We need a detail view at a larger scale.

   
>>
The Reality:
 

In previous tips we have explored the problems regarding sizes of annotations such as text, dimensions, and hatching when creating a scale drawing. We learned about two different methods for solving this problem, but now we have a new dilemma. If we size the annotations correctly for the main drawing, then they will be wrong for the detail at a different scale, and vice-versa.

   
>>
The Solution:
 

Once again, there are two possible solutions and once again each has its advantages and disadvantages. We’ll work through the two solutions and then finish things off by comparing them.

As covered in a previous tip (“SIZE MATTERS: Creating Scale Drawings in CAD”), one solution is to put everything in model space. The other solution is to use paper space layouts with viewports through to the model while the text and dimensions are applied in the paper space layout. Let’s start with the model space solution.

DWGeditor’s Next Top Model…

The first step in the model space solution is to create the detail view itself. There are two ways of doing this.

One way is to simply Copy the required entities and then to use the Scale command to re-size them to the required size. This would seem to be a simple method, and it is in the short term. The problem is that any subsequent changes to the design have to be made twice, once in the basic model and once in the detail copy, with the inherent risk that you will miss something.

The other way is to create a Block of the required entities and then Insert it twice; once at the original location at a 1:1 scale and once at a suitable location at the required scale. The advantage to this method is that if you make any changes, you simply redefine the block and it updates at both locations. The disadvantage to this method arises if you want to apply hatching to the detail. If you apply the hatching before you create the block, then it will get scaled when you insert the block; but you can’t apply hatching to regions within a block insertion.

Hold it! Before you dive in and try either method, we need to discuss the “required” scale factor for both methods.

It all comes back to the same situation.  When we print to a specific scale factor, the Print command scales everything, including the scaled detail; but we want to have the detail printed to a scale factor relative to full size, not relative to the main portion of the drawing. We’re back to that old two wrongs sometimes making a right scenario.

Let’s look at a simple example. Suppose we have a drawing wherein we want the main object to print half size but we want a small detail portion of it to print at twice full size. At first glance, it would seem that we want to use a scale factor of 2:1 for the detail because we want it to be twice the actual size. Ah, but don’t forget that the Print operation will reduce everything to half size, so our 2:1 detail will actually print out at full size, and not the desired twice the size of the actual part.

The solution is to apply a detail scale factor that is equal to the desired detail scale divided by the overall drawing scale. Here are a few typical samples of the number to use. Ignore the DimLFac column for now. I’ll come back to it in a moment.

Drawing scale             Detail scale      Detail scale factor       DIMLFAC
            1:2                               2:1                   4                      0.25
            2:1                               5:1                   2.5                   0.4
            2:1                               10:1                 5                      0.2
            2:1                               20:1                 10                    0.1
            5:1                               10:1                 2                      0.5
            1:96                             1:48                 2                      0.5
            1:48                             1:1                   48                    0.0208333

So far so good, but what happens when we apply dimensions? Assuming we have set a suitable DimScale factor to suit the basic printing scale, then the arrowheads, extension lines, and dimension text will all be the correct size. The only problem is that the detail view is now smaller or larger than full size, and so all the measured values will be wrong by the detail scale factor.

For example, suppose you have a 1”-long line in a 2:1 drawing and in a 5:1 detail view. A dimension applied to the base view will correctly indicate that it is 1” long, but a dimension applied to the detail view will measure it as 2.5”. Oops.

No problem. Here is where the DimLFac (DIMension Linear FACtor) column of the previous table comes into play. When you apply a dimension, DWGeditor measures the distance. Before it fills in the dimension text, however, it multiplies the measured distance by the current setting of the DimLFac (DIMension Linear FACtor) system variable. This defaults to 1.0, but we can set it to anything we want. The correct value, as indicated in the samples in the table, is simply the reciprocal of the Detail scale factor from the table.


Figure 1: Dimensions on Details at Other Scales Require an Adjustment to DIMLFAC.

This procedure could require a lot of flipping back and forth of the DimLFac setting, but there is a simple solution. All you need to do is to create an alternate dimension style with a suitable factor and then simply use the appropriate style when dimensioning the base view or the detail view.

Show Me The Paper…

The other method of handling details at other scales is to use paper space layout viewports. In this case it is not necessary to copy or block the detail view because we are just going to create another layout viewport that looks at a smaller portion of the drawing at a different scale. For our example, we’ll use the same 2:1 and 5:1 scales as previously noted.

  • Click on a layout tab to make it current.
  • Use the MView command to create two viewports through to model space.
  • Double-click on a viewport boundary to invoke the EntProp command.
  • Set the Scale to be 2.0.
  • Click on OK.
  • Double-click inside the viewport to reach into model space.
  • Pan as required to attempt to bring the desired area of the drawing into view. You may not be able to see everything you want to, but do not zoom or use the mouse scroll wheel because this will mess up the scale.
  • Double-click outside the viewport to return to the paper space layout.
  • Grip-edit the viewport boundary as required to re-size it until it shows everything you want. 
  • Repeat the process again on the other viewport, using the appropriate detail scale factor. In the case of our example it will be 5:1.

This method is much simpler in that it is not necessary to copy or block or re-draw anything. It is also not necessary to calculate any compound scaling factors. If you want a detail at a specific scale, then simply set the layout viewport scale factor directly to that value. In addition, if changes are made then they automatically update in both viewports.

The only downside is that dimensioning gets slightly more complicated. There are two possibilities here:

1. The first possibility is to set the DimScale factor to 0.0 and DimLFac to 1.0. Now apply all dimensions in the paper space layout. They will automatically compensate for the viewport scale factor as they are created. This is the simplest, but has the disadvantage that the dimensions are not visible when we are working on the model in model space.

2. The second possibility is to create a layer for each view scale. Apply the dimensions in model space on the appropriate layer, using the correct DimScale and DimLFac values for each viewport scale. Now go to the paper space layout, double-click inside each viewport in turn, and use the ExpLayers command to freeze and thaw the dimension layers so that only the correct one shows in each viewport.


Figure 2: Model-Space Dimensions in Paper-space Viewports Need Different DIMLFAC Values & Separate Layers. Paper-space Dimensions Don’t.

In any case, hatching is handled the same way as the second case. We need to create a hatching layer for each scale and then apply hatching with an appropriate scale factor. The layers are then thawed and frozen as appropriate in each viewport. Note that it will probably be necessary to apply hatching to the same regions more than once in order to take care of each viewport scale.

   
>>
Notes to You: 
 

There is no single, perfect method in DWGeditor for handling details at other scales. Each method described here has its advantages and disadvantages. You will need to do a bit of experimenting to see which one is best for your particular circumstances.

Although the temptation was strong, I managed to get through three whole articles on scaling without once mentioning ladders, mountains, or fish (well, I almost made it).

   
>>
Command review:
 
  • Paper Space Layout Viewports:

Keyboard:       MVIEW
Menu:              View > Layout Viewports
Toolbar:           Layouts > Layout Viewports
Alias:               MV

  • Dimension variable Settings: 

Keyboard:       SetDim
Menu:              Settings > Dimension Settings
Toolbar:           Settings > Dimension Settings

  • The Units tab of the Dimension Settings dialog box has entries for:

DIMSCALE   Comprehensive Scale Factor
DIMLFAC Linear Dimension Scaling Factor

   
 
   
> DECODING THE DXF FILES: Can You Count to Two?
   
>>
The Challenge:
 

You want to send or receive CAD files to or from other brands of software, or you want to pass your files over to post-processing software. The later case includes the situation where you want to create CNC G-code files or to perform FEA (Finite-Element Analysis) operations based on your CAD files.

   
>>
The Reality:
 

The DWG file format is the de facto standard for CAD files but the DWG file format changes every few years (there are now about 14 versions of it) making it cumbersome for 3rd-party applications and machining applications to stay current. Also, it contains far more information than what may be needed by the post-processor applications.

   
>>
The Solution:
 

The DXF (Drawing eXchange Format, or Drawing interchange Format) file format was developed very early in the game. It is well-documented and only ever changes in a predictable way. DXF files can be edited or even created by a simple text editor such as Notepad. In addition to DWGeditor™, most CAD-related programs can open and create DXF files. I have even seen specialty niche-market programs that never bothered developing their own file format but simply use DXF instead.

This tip will explore the format of DXF files, how they work, and how to fix them if they don’t.

The DXF file format is remarkably simple. Anyone who can count to two can figure it out. Let’s work through a simple example to see what I mean.

Start a new drawing and create three new layers. Create a line, a circle, an arc, and some text, putting each entity on a different layer, including one entity on layer 0 (zero). Save it using the name DXF-TEST-01.


Figure 1: Create a simple drawing so we can study its DXF file.

Get Out of Here…
Start the DXF Out command by typing DXFOUT. When the dialog appears, click on Save to create a DXF file whose base name is the same as the current drawing (DXF-TEST-01). Enter V to use the Version option, enter R, and then press Enter to accept an accuracy of 6. Note that although you have clicked the Save button in the dialog box, the file isn’t actually created until you press Enter to accept the accuracy value.

Start Notepad. Select Files of type: and click on All files (*.*). Open your new DXF-TEST-01 DXF file. You will be faced with a screen full of mostly numbers and a few words. Careful study, however, reveals the following facts:

  • DXF files always contain an even number of lines (if you can count to two…);
  • the odd-numbered lines are always integers;
  • the even-numbered lines may contain words, integers, or decimal numbers;
  • the number zero by itself turns up quite often, and if it is on an odd-numbered line then the next line always contains a word.

Before continuing, let’s look at the basic format of a DXF file. It consists of several sections, the number and type of which varies a bit depending on the release and the contents of a particular drawing. It typically includes most of the following:

  • The HEADER section holds all the generic information that applies to the entire drawing. Including things like the software version number, the extents and limits, and the settings of any system variables such as running object snap settings, snap increments, if ORTHO and/or SNAP are on or off, all the dimension variable settings, units settings, and so on.
  • The TABLES section contains items that may have one or more sets of data, such as linetype definitions, layer names and definitions, text styles, dimension styles, and so on.
  • The BLOCKS section contains the name of each block definition, and each definition in turn includes a definition of all the objects that make up each block definition.
  • The ENTITIES section lists everything there is to know about each entity (line, circle, arc, block insertion, etc.) within the drawing.

By scrolling down through your DXF file, you will see several sets of four lines that look like this:


where <word> is one of the key words that I outlined above: HEADER, TABLES, BLOCKS, ENTITIES, or OBJECTS. Each of these four-line sets indicates the start of a new section of the file.

Use Notepad’s Search function to find the word ENTITIES. It will jump ahead in the file to four lines that look like this:

Obviously, the following SECTION of the file describes the ENTITIES in the drawing.

Let's study the ENTITIES section in more detail. Don’t forget, everything works as pairs of lines. Each pair is referred to as a group, and it takes several groups to define a single entity.

Your file will look something like this:

To make it easier to explain things, here is the same data again but this time I have added an extra blank line between each group, two blank lines between each entity, I have added line numbers, and my explanations are in the right-hand column. Your values in the even-numbered lines will probably be different.

That's it! These eight groups are the minimum needed to define a line. Additional optional groups may be present to specify optional parameters if a line's color, linetype, line weight, and so on are different from the layer it is on.

DXF files using more recent formats include additional groups that I have not shown here. Specifically, each entity will include a 5 group for handles and one or more 100 groups that define AcDbxxx items. These can be ignored for our purposes, which is why I had you DXFout as R9.

Let's carry on and look at more of the file.


And here is the last portion of it.

Note that all sections must end with the ENDSEC group, and all DXF files must end with the EOF group.

Now let's work the other way around; use your text editor to change the values in the 10 and 20 groups (that is, the even-numbered lines that follow the 10 and 20 values in the odd lines). For example, lines 11 and 12 from my example currently show
  20
 1.0

If you were to change the 1.0 to 3.875, then you would be changing the y‑coordinate of the start of the line.

You can also change the values in the lines following the 40, 50, and 51 group codes as well as the line of text following the 1 group, but DO NOT CHANGE ANY OF THE ODD-NUMBERED LINES or anything following a 0 (zero), 5, or 100 group code.

Save the modified file as DXF-TEST-02 DXF. Note that the file extension must be DXF, and not the default .TXT that some implementations of Notepad want to add.

Incoming!
Return to DWGeditor and start the Open command. Go to the bottom of the file dialogue box and select Drawing Exchange Format (DXF) from the Files of type: drop list, and then double-click on the name of your DXF-TEST-02 DXF file.


Figure 2: The drawing was edited by revising its DXF file with Notepad.

A quick comparison with the original drawing will show that this version is different. The entities in it have start, end, center, radius, and text values that match your revisions to the DXF file. Congratulations, you have just edited a drawing using Notepad instead of a CAD program because you now understand the basic workings of a DXF file.
   
>>
Notes to You: 
 

Ah, but it gets better than that. Now that you know the rules, you can even create drawings using a program as simple as Notepad. Googling dxf group codes will return many different listings, such as mandatory and optional requirements by entity type or codes in numerical order and so on.

Binary DXF is another variant of the DXF format. It produces files that are much smaller, but they are also much harder to analyze and understand. They are rarely used.

You may find the odd DXF file that won't open properly. DWGeditor simply skips over the bad entity and ignores it without warning. Common errors can include:

  • Illegal entity types following a group 0 (zero) code. A CIRCLE is valid but a CRKL is not;
  • incorrect data types. The group code may require a numeric value but the file holds a text string;
  • an INSERT entity references a block name that is not defined in the BLOCKS section;
  • an entity references a layer or linetype that does not exist in the TABLES section;
  • text or dimension entities reference text or dimension styles that do not exist in the TABLES section.

When DWGeditor encounters the last two; it simply converts text and dimensions to the STANDARD style, lines to CONTINUOUS, and creates a new layer with the continuous linetype and color white. Other applications might not be so polite. In fact, DWGeditor will open a DXF file that doesn’t even have a header and use the default values as just described.

Now that you know how DXF files work, you can use a text editor to correct things and as a fast way of editing a drawing. I once needed to change the width of several hundred PLINEs on a printed circuit board. I exported the file in DXF format, did a "search and replace" for all the line widths, and then saved and opened the revised DXF file.

Let’s finish up with two final warnings on DXF files.

  • First, like any translation they may not be exact, because other systems do not always have exactly equivalent entity types or properties.
  • Second, if you pick a DXF type earlier than the current release, then some drawing information may be lost or converted if the drawing contains types of entities that are not supported in the earlier version.
   
>>
Command review:
 
  • DXFout lets you export specific entities or the entire drawing.
    • Keyboard:       DXFout

There are two other ways of exporting to a DXF file. You can select the desired version from the drop list in the file dialog box in either command.

  • Save As
    • Keyboard:       SaveAs
    • Menu:              File > Save As…
  • Export to File
    • Keyboard:       Export
    • Menu:              File > Export to File
   
 
 
 
>> SIGN UP for SolidWorks Express Newsletter and get the tips and tricks delivered into your inbox every two weeks!