April 23, 2019

Have Your Own 'Style'

Do you use the 'Copy And Paste' functionality in the software you use? Obviously, everybody does that! But that is not the real question.

When you copy something from a document and paste it into another document of same type, you expect it to be exact copy of the original. Now the real question - Have you ever encountered a situation when the copy is not the same (that too by the look) as the original?

Well, I did recently, in one of my projects. When I copied an AutoCAD table from one drawing to another, the text in the table visually looked different from the original.

As you may be aware, every CAD software controls display of its contents by 'styles'. And there are many of them like Dimension Style, Table Style. Text Styles, that control the display of text (font / size / formatting),  are common across all CAD softwares - 2D or 3D.

AutoCAD provides default styles for each category of styles (And it is no different for Inventer / SolidEdge / SolidWorks / ProE - Creo / CATIA).  It is a good practice not to tamper with any of the default styles. If you need any change, even a minor one, create a new style of your own. But leave the default styles untouched. I learned this message loud and clear.  Here is how it happened all.

This particular project required me to create an AutoCAD table in the Customer's existing drawing, collect some information from that drawing and fill the table, using VisualLISP code, with that information.

For a  trial, I created a new drawing, created a table in it and played with the table until it looked perfect. Then I opened the Customer's drawing and copy-pasted the table in that drawing. The result (shown below) was unexpected. It seemed as if these were two different tables.

The Source Table
The copy of the table in Customer Drawing

Its obvious from the first look that there seems to be some mismatch with fonts. The fonts, in AutoCAD, are controlled by the Text Style.

In this particular case, I had made no changes to any of the settings that control the fonts nor had I changed any default settings while creating the table.

So, after some thoughtful moments, I decided to first compare the settings related to table in both the drawings. In both the the drawings, Table Style (that controls the formatting of tables) & Text Style (that controls the formatting of text) user were 'Standard' - the default styles. With these settings, the look and size of the text in table should theoretically be the exactly similar. But it wasn't. And that meant something was wrong somewhere.

On further detailed investigations, I found out that the Customer had modified the font in the 'Standard' text style - from default 'Arial' to 'txt'. 

The situation was ideal to throw the ball back into Customer's court and ask them to 'repair' and restore the 'Standard' text style in their drawing. But that might create another set of problems for the Customer (... not good, you see!). And who am I to advise the Customer to change their default settings?

So, taking matter into my own hands instead, I created a new text style in my drawing that was exact copy of the 'Standard' text style (in my drawing). I applied the new text style to text inside all the cells in the table. This did not make any difference to the text formatting in my drawing and the table displayed exactly as it appeared before.

When I copied the modified table in the Customer's drawing, the new text style was copied and applied to the text in the table automatically (This is the default AutoCAD behavior).
The table with new text style
Copy in Customer Drawing Displays correctly












I was then able to run my VisualLISP code successfully to populate 10 rows of data.

This done, my next step would be to educate and cajole the Customer to repair & restore the "Standard" text style.

Till then, the Customer maintains his own 'Standard' text style, me my own. And we live happily ever after.

So, ... till the next cAdventure in APIs .....  have a nice time and don't ever modify your default styles ....







7 comments:

  1. How did you figure out the problem?

    ReplyDelete
    Replies
    1. Thank you 'Unknown' for your comment.
      Finding solution is an investigative process. You list possible solutions and keep on eliminating irrelevant possibilities.
      It takes conceptual understanding of the domain (AutoCAD in this case), experience, trials & errors and luck to arrive at the solution. Sometimes, it take hours to find the solution and you realize it was really easy. That's the fun of it.
      In this case, luckily, it was a bit easy. The appearance of the text is controlled by font which in turn is specified by the text style. So, that's where I concentrated and found the solution.

      Delete
  2. Simple but very important lesson that don't modify the default styles in CAD Software ...

    I have one question here. Does the default text style other than 'standard' plays any role in this. What would be happened if the drawing in which the table being pasted is -
    i) The settings or font of 'standard' text style is intact,

    ii) however, the default text style is set other than 'standard'
    (say 'S1') and font associated to 'S1' is other than 'Arial'
    or txt'.

    In this case the appearance of font will be normal?

    ReplyDelete
    Replies
    1. Thank you Ganesh More for your comment.
      What I meant by 'default' text style, is that it is provided, by default, by AutoCAD - like the '0' layer.
      What you are probably referring to is 'active' text style.
      When you copy an object from one drawing and paste it into another drawing, the copied object brings in its own properties ('Standard' text style in this case). For example, if the copied object had a different text style which did not exist in the destination drawing, that text style would be created in the destination drawing.
      The active text style in the destination drawing has no effect on it.
      Another example is, if you copy a block reference from one drawing to another, the block definition is automatically created in the destination drawing.
      But since 'Standard' text style also exists (by default) in the destination drawing, it takes the sub-properties (font) of its own, rather than the of the drawing it was copied from.
      Thus, the pasted table text did have the same text style as the the source object, but font in that text style as defined in the destination drawing and NOT as defined in the source drawing.
      I hope I have been clear in explaining this.
      Please feel free if you need more clarification.

      Delete
  3. Thank you Mr. Sanjay Kulkarni for the clarifications on my comment / question. My query has been answered clearly.

    Now, awaiting for your next cAdventure in APIs ....

    ReplyDelete
  4. Sanjay Sir, a very good article written by you, explaining the problem and way-outs. Really liked the advice not to change the standard styles, which is by and large a common practice...

    ReplyDelete
    Replies
    1. Thank you Ravi, for your comment.
      I am happy that you found the contents useful.
      You can also share your problems, if any, so that we can discuss and find solution.

      Delete