Author Topic: Architecture 2008 - LtScale - CANNOSCALE - Oh My!  (Read 2709 times)

0 Members and 1 Guest are viewing this topic.

jbuzbee

  • Swamp Rat
  • Posts: 832
Architecture 2008 - LtScale - CANNOSCALE - Oh My!
« on: March 26, 2008, 05:31:02 PM »
Well, I've been enjoying the ease of Annoscale Objects.  I've been able to do away with many reactors that dealt with dimscale, textsize, ltscale, layout switching etc.  The only thing that still bothers me is the 'MSLTSCALE sysvar, that lets CANNOSCALE control linetype scale doesn't work at all with our standard layers and linetypes.  So I started investigating how to controll LineType scale when the CANNOSCALE sysvar changes.  CANNOSCALE command returns SETVAR in a VLR-Command-Reactor event!  How can we use that??  So I came up with the clever way of checking the command prompt to see what's been called:
snip:
Code: [Select]
((if (vl-string-search "CANNOSCALE" (getvar "lastprompt"))
(progn
   (setq DwgDimScale (jb:GetADTVar 40)
Doc      (vla-get-activedocument (vlax-get-acad-object)))
   (vlax-invoke
     Doc
     "setvariable"
     "ltscale"
     (* 0.5 DwgDimScale))
   (vla-regen Doc acActiveViewport)
   )))

Now the AutoCAD dimscale doesn't get changed when CANNOSCALE does, but the ADT Dimscale variable does.  I wrote this little routine for extracting all kind of info from the AECVARS dictionary:

Code: [Select]
;;; ADT Variable Function ;
;;; Layer Standard Drawing (jb:GetADTVar 5) ;
;;; Layer Standard  (jb:GetADTVar 9) ;
;;; Drawing Scale(jb:GetADTVar 40) ;
;;; Annotation size (jb:GetADTVar 42) ;
;;; ;


;;; Return ADT Variable Value ;

(defun jb:GetADTVar  (var / dict vars ret)
    ;check to see if the dict exists, if not initialize it . . .
  (if (not (cdar (dictsearch (namedobjdict) "AEC_VARS")))
    (aeclayerkeylist))
  (setq dict (dictsearch
               (cdar (dictsearch (namedobjdict) "AEC_VARS"))
               "AEC_VARS_DWG_SETUP")
        vars (member '(100 . "AecDbVarsDwgSetup") dict)
        ret  (cdr (assoc var vars)))
  ret)

Anyway, I thought some of you would enjoy seeing a severely hacked work-around - in a reactor no less!  :lmao:

If anyone wants to see the whole reactor code just ask - it's pretty straight forward though.
James Buzbee
Windows 8

KewlToyZ

  • Guest
Re: Architecture 2008 - LtScale - CANNOSCALE - Oh My!
« Reply #1 on: June 20, 2008, 12:36:38 PM »
Actually the reactor the folks had here seems to work fine for our LTSCALE as long as I run:
Code: [Select]
;==========================================================================================================================================Control Line Scaling
(command "PSLTSCALE" 0)
(command "MSLTSCALE" 0)
;==========================================================================================================================================
(prompt "\nMSpace & PSpace LTScale Varaibles set to 0!! Defaults to LTSCALE settings now!")

with the reactor in the acad2009doc.lsp:
Code: [Select]
;;==============================================================================================
;;;; Added from theSwamp.org to check out alternatives to Annotative objects.
;;;; The DIMSCALE line will need commented out to work with annotative objects.
;;; Command Reactor ;
;;; ;
;;; Call-back Functions ;
;;; Command Ended ;
 (defun jb:ADTCommandEnded(calling-reactor commands / dwg annoscale dimscale ltscale)
    (cond
      ((if (vl-string-search "CANNOSCALE" (getvar "lastprompt"))
(progn
       (setq dwg(vla-get-activedocument(vlax-get-acad-object))
     annoscale(vlax-invoke dwg 'getvariable  "CANNOSCALEVALUE")
     dimscale(/ 12(* annoscale 12.0))
     ltscale(* dimscale 1) ;0.5
     )
       (if ltscale(vlax-invoke dwg "setvariable" "LTSCALE" ltscale))
       
       ;***Warning***
       ;The active dimstyle can't be annotative or the next line will bomb.
       ;You could add code to check if not sure . . ..
       
       (if dimscale(vlax-invoke dwg "setvariable" "DIMSCALE" dimscale))
       (vlax-invoke dwg 'regen  acActiveViewport)
       )))
      )
   )

;;; Construct the Command Reactor ;
(defun jb::ADTConstructCommandReactor  (/)
  (if (= (type *jbADTCommandReactor*) 'VLR-Command-Reactor)
    (progn (vlr-remove *jbADTCommandReactor*) (setq *jbADTCommandReactor* nil)))
  (if (/= (type *jbADTCommandReactor*) 'VLR-Command-Reactor)
    (setq *jbADTCommandReactor*
           (VLR-Command-Reactor
             "jbTools Command Reactor"
             '((:VLR-commandEnded . jb:ADTCommandEnded)
               ))
          ))

  (if (not (vlr-added-p *jbADTCommandReactor*))
    (progn
    (vlr-add *jbADTCommandReactor*)
    (vlr-set-notification *jbADTCommandReactor* 'active-document-only)))
  (princ))


;;; load reactors ;

   
(if jb::ADTConstructCommandReactor
  (jb::ADTConstructCommandReactor))
;;==============================================================================================
;;;