Importing DIMSTYLE; setting as ACTIVE DIMSTYLE; and preserving current DIMSCALE

Importing DIMSTYLE; setting as ACTIVE DIMSTYLE; and preserving current DIMSCALE

Anonymous
Not applicable
975 Views
1 Reply
Message 1 of 2

Importing DIMSTYLE; setting as ACTIVE DIMSTYLE; and preserving current DIMSCALE

Anonymous
Not applicable

Hi all, I'm having issues with this LISP in ACAD 2014. I'm unsure why, but the intent is to import a dimstyle via a block depending on the MEASUREMENT variable for Metric and Imperial styles.

 

What I'm running into is each time the command runs, it brings in the dimstyle, but it resets the DIMSCALE to 1 and does not set it as the current dimstyle. Any help is appreciated. Thanks!

 

(defun c:dim_lin (/ ds dskbk dim acdoc) 
(setq	ds	(if (= (getvar 'measurement) 0)
			"s2014"
			"s2014 - M"
		)
	)

(setq	dsbk	(strcat "*" @dwg "dim_" ds ".dwg") 		;define dimstyle block
	dim	(getvar 'dimscale)				;gets dimscale for cmleaderscale
	)

(if 	(tblsearch "dimstyle" ds);test

	(progn						;thenexprs
	(setq	acdoc	(vla-get-activedocument (vlax-get-acad-object)))
	(vla-put-activedimstyle acdoc (vla-item (vla-get-Dimstyles acdoc) ds))
	);endthen

	(progn						;elseexprs
	(command "-insert" dsbk "0,0" "1" "1" "0")	;place dsbk
	(setq	acdoc	(vla-get-activedocument (vlax-get-acad-object)))
	(vla-put-activedimstyle acdoc (vla-item (vla-get-Dimstyles acdoc) ds))
	);endelse
);endif

	
(initcommandversion)
(command ".dimlinear")				;run command
(while 	(> (getvar 'cmdactive) 0)
	(command pause)
	);endwhile
);enddefun
0 Likes
Accepted solutions (1)
976 Views
1 Reply
Reply (1)
Message 2 of 2

hmsilva
Mentor
Mentor
Accepted solution

Hi cgentile,

 

when set as current a different dimstyle, all overrides values will be discarded...

And hoping '@dwg' be a gloval variable... perhaps something like this...

 

(defun c:dim_lin (/ ds dskbk dim acdoc)
  (setq ds (if (= (getvar 'measurement) 0)
             "s2014"
             "s2014 - M"
           )
  )

  (setq dsbk (strcat "*" @dwg "dim_" ds ".dwg") ;define dimstyle block
        dim  (getvar 'dimscale) ;gets dimscale for cmleaderscale
  )

  (if (tblsearch "dimstyle" ds) ;test

    (progn ;thenexprs
      (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
      (vla-put-activedimstyle acdoc (vla-item (vla-get-Dimstyles acdoc) ds))
      (setvar 'dimscale dim)
    )     ;endthen

    (progn ;elseexprs
      (command "-insert" dsbk "0,0" 1 1) ;place dsbk
      (command) ; cancel the insert
      (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
      (vla-put-activedimstyle acdoc (vla-item (vla-get-Dimstyles acdoc) ds))
      (setvar 'dimscale dim)
    )     ;endelse
  )       ;endif


  (initcommandversion)
  (command ".dimlinear") ;run command
  (while (> (getvar 'cmdactive) 0)
    (command pause)
  )       ;endwhile
  (princ)
)         ;enddefun

 

Hope this helps,
Henrique

EESignature

0 Likes