AutoCAD/dashed linetypes
Expert: Scott Cook - 10/21/2010
QuestionQUESTION: AutoCAD 2010 - no relevant 3rd party programs...
dashed linetypes - seems like no matter how many times i
try, i always get a weird result with dashed linetypes. for
instance, one linetype appears "correct" in model space, but
not in paper space. another appears "wrong" in paper space,
but plots "correctly". and another appears "wrong" in any
space and plotted. i have reviewed the properties and the
plot style manager looking for discrepancies, but can't find
any. basically, i just want to draw the @#$%! line and have
it look "correctly" regardless of where i view it. and of
course, most importantly when i plot it. i have a halftone
dashed line that looks "correct" when i draw it in model
space, but plots as a solid line.
thanks!!!
ANSWER: Set both your ltscale and your psltscale to 1. Make sure each model space viewport is set to an appropriate zoom factor, and always plot from paper space.
If you toggle back and forth between paper space and model space a lot, write a macro that sets your ltscale to your drawing scale when operating in pure model space, so that when drawing your lines look right.
---------- FOLLOW-UP ----------
QUESTION: Hi,
OK, it didn't work. I set the ltscale, psltscale and
celtscale to 0. When that didn't work, I tried every
combination I could come up with. Basically, no matter what
I try, a line meant to be dashed is solid when plotted. I
can get it to read as dashed in both model and paper space,
but never when plotted. I am plotting as pdf.
AnswerSet USERR1 to your drawing scale and load up the routine below. Let me know what you think. I'm doing something similar to this at one of my clients and they never have any trouble. For example for a 1/8"=1'-0" drawing, USERR1 should be set to 96.
What this routine does is watch for when you change from paper space to model space, or a model space viewport and sets dimscale, psltscale, and ltscale accordingly. Make sure this routine is always loaded when you are running autocad and your problems should go away.
;;; this is an internal function used to keep dimscale up to date
;;; it hooks into a setvar change notification upon load
;;; this function does all the work, it looks for changes to CVPORT and TILEMODE, if changed sets dimscale appropriately
;;; it reads USERR1 to determine the fixed dimscale value for model space
(defun setvarnotifier (callbacktype variables / tilemode cvport userr1 acadobject doc)
; (princ callbacktype)
; (princ variables)
(setq variables (strcase (car variables))) ;make sure it's upper case
(if (or (= variables "TILEMODE")(= variables "CVPORT")(= variables "USERR1"))
(progn ; it is a variable of interest, proceed
(setq acadobject (vlax-get-acad-object))
(Setq doc (vla-get-activedocument acadobject))
(setq tilemode (vlax-variant-value (vlax-invoke-method doc 'GetVariable "TILEMODE"))
cvport (vlax-variant-value (vlax-invoke-method doc 'GetVariable "CVPORT"))
userr1 (vlax-variant-value (vlax-invoke-method doc 'GetVariable "USERR1"))
)
(if (= (getvar "useri3") 1)(setq metscale 25.4)(setq metscale 1))
(if (= userr1 0)(setq userr1 1)) ; this causes an ERROR if not properly initialized
(cond ((and (= tilemode 0) (= cvport 1)) ;pspace
(vlax-invoke-method doc 'SetVariable "DIMSCALE" metscale)
(vlax-invoke-method doc 'SetVariable "PSLTSCALE" 1)
(vlax-invoke-method doc 'SetVariable "LTSCALE" metscale)
(vlax-invoke-method doc 'SetVariable "TEXTSIZE" (/ 9.0 96.0))
; (princ "\nPSPACE, DIMSCALE automatically set to 1\n")
)
((and (= tilemode 0) (> cvport 1)) ;mspace viewport
(vlax-invoke-method doc 'SetVariable "DIMSCALE" userr1)
(vlax-invoke-method doc 'SetVariable "PSLTSCALE" 1)
(vlax-invoke-method doc 'SetVariable "LTSCALE" metscale) ;don't think we should do this in a viewport
(vlax-invoke-method doc 'SetVariable "TEXTSIZE" (* (/ 9.0 96.0) userr1))
; (princ (strcat "\nMSPACE VIEWPORT, DIMSCALE automatically set to " (rtos userr1 2 2) "\n"))
)
((= tilemode 1) ;mspace
(vlax-invoke-method doc 'SetVariable "DIMSCALE" userr1)
(vlax-invoke-method doc 'SetVariable "PSLTSCALE" 1)
(vlax-invoke-method doc 'SetVariable "LTSCALE" userr1)
(vlax-invoke-method doc 'SetVariable "TEXTSIZE" (* (/ 9.0 96.0) userr1))
; (princ (strcat "\nMSPACE, DIMSCALE automatically set to " (rtos userr1 2 2) "\n"))
)
(T nil)
)
)
)
;(princ "\n\n")
(princ)
)
(defun pspacenotifier (callbacktype variables / variables tilemode cvport userr1 acadobject doc)
(setq variables (strcase (car variables))) ;make sure it's upper case
(if (= variables "MODEL")
(progn ; we have changed to the model space layout
(setq acadobject (vlax-get-acad-object))
(Setq doc (vla-get-activedocument acadobject))
(setq tilemode (vlax-variant-value (vlax-invoke-method doc 'GetVariable "TILEMODE"))
cvport (vlax-variant-value (vlax-invoke-method doc 'GetVariable "CVPORT"))
userr1 (vlax-variant-value (vlax-invoke-method doc 'GetVariable "USERR1"))
)
;mspace
(if (= userr1 0)(setq userr1 1)) ; this causes an ERROR if not properly initialized
(vlax-invoke-method doc 'SetVariable "DIMSCALE" userr1)
;(princ (strcat "\nMSPACE, DIMSCALE automatically set to " (rtos userr1 2 2) "\n"))
)
(progn ;else we have changed to a layout, figure out what the scoop is
(setvarnotifier T (cons "CVPORT" T))
)
)
;(princ "\n\n")
(princ)
)
(vl-load-com)
(vlr-sysVar-Reactor nil (list (cons :vlr-sysVarChanged 'setvarnotifier)))
(vlr-miscellaneous-reactor nil (list (cons :vlr-layoutSwitched 'pspacenotifier)))
;;;--------------------------------------------------------------;
;;; Function: CleanReactors ;
;;;--------------------------------------------------------------;
;;; Description: General utility function used for cleaning up ;
;;; reactors. It can be used during debugging, as ;
;;; well as cleaning up any open reactors before ;
;;; a drawing is closed. ;
;;;--------------------------------------------------------------;
(VLR-DWG-Reactor nil (list (cons :vlr-beginClose 'Clean-dimscale-Reactors)
;(cons :vlr-databaseToBeDestroyed 'Clean-dimscale-Reactors)
))
(defun Clean-dimscale-Reactors (callbacktype variables)
(vlr-remove-all :VLR-Miscellaneous-Reactor)
(vlr-remove-all :VLR-SysVar-Reactor)
(vlr-remove-all :VLR-dwg-reactor)
; (vlr-remove-all)
)