Results 1 to 3 of 3

Thread: Setting DimStyle

  1. #1
    I could stop if I wanted to pnorman's Avatar
    Join Date
    2005-02
    Location
    Calgary
    Posts
    203
    Login to Give a bone
    0

    Cool Setting DimStyle

    Hi,
    I have some experience with AutoLisp but am new to Reactors and "vla-" functions.
    I want to execute the following lisp within a reactor callback:

    (if (tblsearch "dimstyle" "my_dimstyle")(command "dimstyle" "restore" "my_dimstyle"))

    but of course I cannot use the "command" function in a reactor.
    I would like a "vla-" alternative to the above please. I think I need to use "vla-put-activedimstyle" but I cannot work out how to make it work.

    Thanks
    Phill

    PS Here is the callback function I want to use it in:

    Code:
    (defun ppn_reactor_tm (ppn_reactor_name ppn_layout_name / MS_SC)
      (if (= (setq *SC* (getvar "dimscale")) 0.0)
        (setq *SC* 1)
      )
      (if (= (car ppn_layout_name) "Model")
        (progn
          (if (/= (setq MS_SC (getvar "userr1")) 0.0)
    	(progn
    ;;; Insert dimstyle restore here
    	  (setvar "dimscale" MS_SC)
    	  (setq *SC* (getvar "dimscale"))
    	  (setvar "ltscale" (* *SC* 7.62))
    	)
    	(progn
    ;;; Insert dimstyle restore here
    	  (setvar "dimscale" *SC*)
    	  (setvar "ltscale" (* *SC* 7.62))
    	)
          )
        )
        (progn
          (setvar "userr1" (getvar "dimscale"))
    ;;; Insert dimstyle restore here
          (setvar "dimscale" 1.0)
          (setq *SC* 1.0)
          (setvar "ltscale" (* *SC* 7.62))
          (if (/= (getvar "PSLTSCALE") 1)
    	(alert "PSLTSCALE is not set to 1.\nPlease check.")
          )
        )
      )
      (princ)
    )
    
    (vlr-miscellaneous-reactor
      nil
      '((:vlr-layoutSwitched . ppn_reactor_tm))
    )
    Last edited by Glenn Pope; 2005-03-25 at 02:24 PM. Reason: Placed code in code tag

  2. #2
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: Setting DimStyle

    Well, I didn't go through the rest of your code but this little snippet should get you going.....BTW, *doc* is a global var I use.....either set it in this routine to be the activedocument or use your own global for it.
    Code:
    (if (tblsearch "dimstyle" "my_dimstyle")
      (progn
        (setq dstyl (vla-item (vla-get-dimstyles *doc*) "my_dimstyle"))
        (vla-put-activedimstyle *doc* dstyl)
        )
      )
    Good Luck!

  3. #3
    I could stop if I wanted to pnorman's Avatar
    Join Date
    2005-02
    Location
    Calgary
    Posts
    203
    Login to Give a bone
    0

    Smile Re: Setting DimStyle

    Quote Originally Posted by miff
    Well, I didn't go through the rest of your code but this little snippet should get you going.....BTW, *doc* is a global var I use.....either set it in this routine to be the activedocument or use your own global for it.
    Code:
    (if (tblsearch "dimstyle" "my_dimstyle")
      (progn
        (setq dstyl (vla-item (vla-get-dimstyles *doc*) "my_dimstyle"))
        (vla-put-activedimstyle *doc* dstyl)
        )
      )
    Good Luck!
    Thanks Miff
    That worked perfectly. Here is the completed code if anyone's interested!! Not sure if it has all the necessary checks and balances but thats that... I use it in conjunction with the defun c:ds below.

    Cheers
    Phill
    Code:
    ;;;
    ;;;
    ;;;
    (vl-load-com)
    
    (setq *acad-object* nil)***** ; Initialize global variable 
    (setq *active-document* nil)* ; Initialize global variable 
    (setq *model-space* nil)***** ; Initialize global variable 
    
    (defun acad-object () 
     (cond (*acad-object*)****** ; Return the cached object 
    ** (t 
    *** (setq *acad-object* (vlax-get-acad-object)) 
    ** ) 
     ) 
    ) 
    
    (defun active-document () 
     (cond (*active-document*)** ; Return the cached object 
    ** (t 
    *** (setq *active-document* (vla-get-activedocument (acad-object))) 
    ** ) 
     ) 
    ) 
    
    (defun model-space () 
     (cond (*model-space*)****** ; Return the cached object 
    ** (t 
    *** (setq *model-space* (vla-get-modelspace (active-document))) 
    ** ) 
     ) 
    ) 
    
    (defun ppn_set_activedimstyle (my_dimstyle / my_dimstyle_ob)
      (if (tblsearch "dimstyle" my_dimstyle)
        (progn
          (setq my_dimstyle_ob (vla-item (vla-get-dimstyles (active-document)) my_dimstyle))
          (vla-put-activedimstyle (active-document) my_dimstyle_ob)
        )
      )
    )
    
    ;;;
    ;;;   Tilemode Toggle
    ;;;
    
    (defun ppn_reactor_tm (ppn_reactor_name ppn_layout_name / MS_SC)
      (if (= (setq *SC* (getvar "dimscale")) 0.0)
          (setq SC 1)
      )
      (if (= (car ppn_layout_name) "Model")
        (progn
          (if (/= (setq MS_SC (getvar "userr1")) 0.0)
    	(progn
                      (ppn_set_activedimstyle "my_dimstyle_name")
    	  (setvar "dimscale" MS_SC)
    	  (setq *SC* (getvar "dimscale"))
    	  (setvar "ltscale" (* *SC* 10))
    	)
    	(progn
                      (ppn_set_activedimstyle "my_dimstyle_name")
    	  (setvar "dimscale" *SC*)
    	  (setvar "ltscale" (* *SC* 10))
    	)
          )
        )
        (progn
          (setvar "userr1" (getvar "dimscale"))
          (ppn_set_activedimstyle "my_dimstyle_name")
          (setvar "dimscale" 1.0)
          (setq *SC* (getvar "dimscale"))
          (setvar "ltscale" 10.0)
        )
      )
      (princ)
    )
    
    (vlr-miscellaneous-reactor nil '((:vlr-layoutSwitched . ppn_reactor_tm)))
    ;;;
    ;;;   end tilemode toggle
    ;;;
    (defun c:ds ( / SC#)
      (initget 4)
      (if (setq SC# (getreal (strcat "\nEnter new value for drawing scale <" (rtos (getvar "dimscale")) ">: ")))
          (progn
            (setq *SC* SC#)
            (if (zerop *SC*) (setq *SC* 1))
          )
          (progn
            (setq *SC* (getvar "dimscale") SC# *SC*)
            (if (zerop *SC*) (setq *SC* 1))
          )
      )
      (setvar "ltscale" (* *SC* 10))
      (command "style" "ppn" "arial" (* 2.20 *SC*) "1" "10" "_n" "_n")
      (command "dimstyle" "restore" "ppn")
      (setvar "dimscale" *SC*)
      (if (= (getvar "tilemode") 1) (setvar "userr1" *SC*))
    (princ)
    )
    Last edited by Glenn Pope; 2005-03-25 at 02:25 PM. Reason: Placed code in code tag

Similar Threads

  1. Dimstyle Help Needed -
    By samsami546995 in forum CAD Standards
    Replies: 2
    Last Post: 2011-03-09, 03:40 AM
  2. dimStyle
    By eng.ims134 in forum ARX
    Replies: 1
    Last Post: 2010-07-02, 08:06 AM
  3. To set a new DIMstyle
    By devitg.89838 in forum AutoLISP
    Replies: 8
    Last Post: 2010-02-22, 07:08 PM
  4. DIMSTYLE changes?
    By kane333 in forum AutoCAD General
    Replies: 1
    Last Post: 2008-10-06, 05:02 PM
  5. Save reminder - system setting or project setting?
    By patricks in forum Revit Architecture - General
    Replies: 4
    Last Post: 2005-07-08, 01:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •