Monday, November 16, 2015

Autocad Dimension Crazy!

Well, maybe not crazy, but a little irritating.

I have just gone back to by old work for a short time to earn a few dollars to pay for a tooth that fell out.

The man who took over from me is an engineer, and while fairly familiar with Autocad, it was not his main thing for most of his career.  He tells me that he finds drafting is a nicer job than being an engineer.  Let's hope this remains the case!

The task he has partially completed is enormous in size, covering several levels of plant and several buildings.

They also had  a friend of mine filling in for a time, so I have been opening up some of their drawings and working on them.  Their drawings are fine, except for one thing: dimensions.

In the past, I would open my template drawing, draw the model in modelspace, jump out to paperspace and start dimensioning with my 1:1 dimension style.   It did not matter what zoom factor the viewport had, it would always give the correct dimension.

Now I find that I have to set dimlfac to whatever the viewport zoom factor is.  This is a nuisance, especially as I had no firm idea what the problem was.

A little bit of research on the net and things became clear:

If you set DIMASSOC to 2, Autocad will take the zoom factor of the viewport into account when filling out the dimension.

I have raved on about zero height text in a previous blog, here:  http://wlecouteur.blogspot.co.nz/search?q=dimstyle

Nowadays, If my dimensions and text are not to my liking I just blast the drawing with 2 lisp routines:

1. DS.lsp which is in the link above, a simple routine, which I have extended below  a bit to cope with the various text styles I did come across. All the things after a ; are comments to explain things

(defun c:DS()
(setq skale (getreal "Please enter the plotted scale: "));get a scale from the user and assign it to skale
(command "-style" "STANDARD" "ARIAL"
                        "0" "1" "0" "" "" );issue the style command and make it Arial font

(if (tblsearch "style" "ROMANS")(command "-style" "ROMANS" "ARIAL" "0" "1" "0" "" "" ""))
(if (tblsearch "style" "R1")(command "-style" "R1" "ARIAL" "0" "1" "0" "" "" ""))
(if (tblsearch "style" "R1-25")(command "-style" "R1-25" "ARIAL" "0" "1" "0" "" "" ""))
(if (tblsearch "style" "R2")(command "-style" "R2" "ARIAL" "0" "1" "0" "" "" ""))
(if (tblsearch "style" "R5")(command "-style" "R5" "ARIAL" "0" "1" "0" "" "" ""))
;;;the above just checks out the other styles in the drawing and sets them all up to zero height text

(setvar "MIRRTEXT" 0) ; hard to believe - some people set their mirror command to be a bit silly
(setvar "DIMSCALE" SKALE); so if you typed 1 as the plotted scale, dimscale gets set to 1
(setq the_textsize (* skale 2)) ;setting a variable up to be used next line ie if dimscale= 2
;the textsize will be set to 2 * 2 = 4
(setvar "textsize" the_textsize) ;the system variable set to that value
(setvar "dimassoc" 2); will take the zoom factor of the viewport into account
;funny, I had forgotten I had put this line in a zillion years ago!
(princ);exits quietly
);end of the defined function

2. The other lisp is called Dimlo.lsp
;imports a dummy block containing a set of dimension styles
(defun c:Dimlo()
(command "-dimstyle" "r" "STANDARD")
;sets the current style to STANDARD
(command "-insert" "dimstyles"  "0,0" "1"     "1"       "0"); inserts a block called dimstyles
(command "-dimstyle" "R" "1-1");issues the dimstyle command and restores it to 1-1
(command "erase" "l" "");then erases the block from the drawing
(princ)
)

The block called dimstyles is just a rectangle (just something to fill in the drawing-,may not even be necessary), but in the drawing all the dimension styles normally used are set up, eg 1-1, 1-2, 1-5 and so on.  Normally in paper space you would use 1:1, so very little setting up is needed.  Sometimes you have to put dimensions in paper space, so you can choose 1:2 if you need to from the dimension styles pull down.

There is no reason why you could not make up such a block and get all your dimension styles all set up in that one block.

This is close to the idea of a virus used in Autocad, but in a good way!

The only problem is that it illustrates how easy it is to get away from how Autocad works using automation, ie lisp routines, to accomplish a simple task, and how strangely rooted in the past some people are. this command came out in 2004.

Other not recommended things are clicking on a dimension and changing it's value; This should never be done! The reason is anyone coming into your drawing will find this (if they are lucky!), then will not trust any of the other dimensions.

As for exploding dimensions-very naughty!

I have been thinking about putting all my lisp routines on a new web page, probably around Christmas time.  If you are keen for that, post a comment. If nobody posts I may get lazy and not do it.




1 comment:

Unknown said...

I need more articles and blogs please post soon. ITL retailer