Jump to content

Reactors for switching beween Model/Paper Space


lpseifert

Recommended Posts

Maybe someone could point me in the right direction... ultimately I want to set the dimscale when switching between MS/PS; set the dimscale to be the same as the VP scale (e.g. VP Scale- 1"=50', Dimscale=50; or maybe use the Cannoscalevalue) and set the Dimscale=1 when switching to PS. I can't seem to find the correct Event to use in the reactor. Any ideas?

Be forewarned this is my first attempt at using reactors.

Thanks-

Link to comment
Share on other sites

here's a sample lpseifert, i think you can move from here.....'-)

 

(vl-load-com)
(defun chtab ()
   (if    (not ct_rea)
   (setq
       ct_rea (vlr-miscellaneous-reactor
              nil
              '((:VLR-layoutSwitched . yourlispnamegoeshere))
          ) ;_ end_vlr-sysvar-reactor
   ) ;_ end_setq
   ) ;_ end_if
) ;_ end_defun
(chtab)

(defun yourlispnamegoeshere (event parameter)
   (princ "YOU SWITCHED LAYOUT")
) ;_ end_defun

 

*edit*

i see you're already looking for the event, i'll check what i can dig

Link to comment
Share on other sites

Thanks wizman, but I believe this will invoke a reactor when you switch layout tabs; I was hoping for a reaction to switching from MS to PS (and vice versa) on the same layout tab.

Link to comment
Share on other sites

please try lpseifert:

 

 

(vl-load-com)
(defun chspce ()
   (if	(not ch_spce)
(setq
    ch_spce (vlr-sysvar-reactor
		nil
		'((:vlr-sysvarchanged . yourlispnamegoeshere))
	    ) ;_ end_vlr-sysvar-reactor
) ;_ end_setq
   ) ;_ end_if
) ;_ end_defun
(chspce)

(defun yourlispnamegoeshere (event parameter)
   (If	(eq (car parameter) "CVPORT")
(princ "YOU SWITCHED SPACE")
   ) ;_ end_If
) ;_ end_defun

Link to comment
Share on other sites

Thanks so much wizman, that triggers the reactor when I switch. May I ask what is the usage of the variables 'event' and 'parameter'? Autodesks Help isn't real helpful with vlr- functions.

Link to comment
Share on other sites

your welcome lpseifert, those are resultant arguments from the triggering of the reactor, event is the reactor object and the parameter is a list of elements which varies for particular events

 

particularly for :vlr-sysVarChanged:

 

parameter is a list of composed of 2 items namely

 

First parameter is a string identifying the system variable name. (thats why CAR was used)

 

Second parameter is symbol indicating whether the change was successful (T if successful, nil if not).

 

 

have a look also a vlisp bible, it has also a good reactor discussion.

Link to comment
Share on other sites

Here's what I've got so far, maybe someone will find it useful. Seems to work OK for the scales I use, I haven't tested architectural scales.

Thanks to wizman, he did the heavy lifting.

;;;Reactor to set Dimscale when switching spaces LPS/wizman 2009-02

(vl-load-com)
(defun chspce ()
 (if (not ch_spce)
   (setq
     ch_spce (vlr-sysvar-reactor
       nil
       '((:vlr-sysvarchanged . setscale))
         ) ;_ end_vlr-sysvar-reactor
   ) ;_ end_setq
 ) ;_ end_if
) ;_ end_defun
(chspce)

(defun setscale    (event parameter)
 (If (eq (car parameter) "CVPORT")
   (if    (eq (getvar "cvport") 1)
     (progn
   (setvar "dimscale" 1)
   (setvar "textsize" 0.1)
     ) ;_ end of progn
     (progn
   (setvar "dimscale" (/ 1 (getvar "cannoscalevalue")))
   (setvar "textsize" (* (/ 1 (getvar "cannoscalevalue")) 0.1))
     ) ;_ end of progn
   ) ;_ end of if
 ) ;_ end_If
) ;_ end_defun

I was hoping to set the dimscale by extacting dxf codes of the viewport, but couldn't figure out how to entsel without actually picking the viewport border. Anyone have any ideas how?

Link to comment
Share on other sites

this should select your viewport

 

(if
(setq ss_vp
 (ssget "_x"
  (list
   (cons 410 (getvar "ctab"))
   (cons 0 "VIEWPORT")
  );list
 );ssget
);setq
 (setq ent_vp
  (entget
   (ssname ss_vp 0)
  );entget
 );setq
);if

Link to comment
Share on other sites

Thanks alanjt, that worked fine.

Thanks Lee, using entget retrieved the code as a tblsearch would have (I think) but I needed the codes for the viewport to determine the viewport scale - dxf code 45/41.

I wanted to do it that way instead of using the cannoscalevale variable because people around here use Zoom xp factors when they change the viewport scale and that doesn't change the cannoscale.

Link to comment
Share on other sites

No problem Larry, just wanted to supply an alternative.

 

If I was to find the solution to this problem, the first thing that would spring to mind would be the solution supplied by Alanjt, but I am trying to learn more and more of VL, so I strived for an alternative :P

 

Cheers,

Lee

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...