Jump to content

Lisp that changes LTScale for Paper Space


jbush2404

Recommended Posts

Can someone help me with a lisp that will automatically change my LTScale to .3 when I go to Paper Space and then go back to normal when I switch to Model Space?

 

We had a lisp for 2009 but it quit working when we switched over to 2010. Thanks for any help you can give me.

Link to comment
Share on other sites

I'd also like to know. You could have a sysvar reactor checking for changes in CTAB or TILEMODE and then modify the LTSCALE accordingly. But I think that's a whole lot of trouble for something which is not needed at all.

 

I just do the following: PSLTSCALE=1 in all layouts, MSLTSCALE=1 in model tab, LTSCALE=whatever you prefer (throughout the entire DWG - one size fits all), in model tab CAnnoScale=something reasonable instead of 1:1. That way your linetypes adjust according to the scale applied - thus their dash lengths stay constant on the plotted paper. And due to the MSLTSCALE & CAnnoScale it appears correct even in Model space. No need to constantly set and reset LTSCALE as you had to with 2007 and before. You don't need to use Annotative objects to have this feature work for you, if you're scared of Annotative.

Link to comment
Share on other sites

We use to use a lisp routine here at our office that would change the ltscale to .3 in paperspace when you clicked on a paperspace tab. That lisp no longer works so we have been manually having to change the ltscale and have wasted a ton of paper in the process (due to the line types not being correct).

 

I believe we need it in lisp format so that we can drop it in the lisp folder on the server and it will do its magic on all the machines in the office. (I am not a autolisp person at all so I have no idea).

Link to comment
Share on other sites

can you post that lisp? it may be easier to modify it than to start from scratch. But I too am curious as to why you need this. Perhaps it is something your company has been doing forever, and it is time for an update in procedure.

Link to comment
Share on other sites

Against my better judgement. Maybe try this lisp:

(vl-load-com)
(setq LTScale:Factor 0.5)
(defun LTScale:React (ro inf / sc)
 (cond
   ((wcmatch (car inf) "TILEMODE")
    (if (<= (setq sc (getvar "DIMSCALE")) 1.0)
      (setq sc (/ 1.0 (getvar "CANNOSCALEVALUE")))
    )
    (setvar "LTSCALE" (if (= (getvar "TILEMODE") 1) (* sc LTScale:Factor) LTScale:Factor))
   )
 )
)
(apply '(lambda (rlst / rlst item ro)
         ;; Clear reactors
         (setq rlst (vlr-reactors))
         (foreach item rlst
           (foreach ro (cdr item)
             (if (= "LTScale" (vlr-data ro))
               (vlr-remove ro)
             )
           )
         )
       )
      (list 1)
)
(VLR-Reaction-Set (vlr-sysvar-reactor "LTScale") :vlr-sysVarChanged 'LTScale:React)

I'm not sure what you'd use to define how the LTScale should be shown in the model tab. I've simply used the DIMSCALE sysvar (which is the overall dimension scale factor) or if that's 1.0 or smaller, then I've used the inverse of the Anno Scale value. This portion you need to alter to suit your particular requirements. Also change the 0.5 in (setq LTScale:Factor 0.5) to whatever you prefer, e.g. (setq LTScale:Factor 0.3).

 

This basically accomplishes the exact same thing as happens automatically when you follow my previous post's description. It just constantly changes LTSCale back and forth, wheras the other method just adjusts the display of the linetypes according to the current CAnnoScale and that inside each viewport.

 

BTW, if you force yourself into using this old-hat way of working with LTSCALE then also make sure you turn off all the automatic scaling. I.e. PSLTSCALE=0 and MSLTSCALE=0. I just hate doing this, since now you can't get linetypes to work properly when you've got 2 viewports at differing scales.

Link to comment
Share on other sites

irneb, :VLR-layoutSwitched might be of interest. I used it in an old LTScale reactor, but the introduction of MSLTScale rendered it useless.

Link to comment
Share on other sites

Irne,

 

If you don't mind, I have a few questions about your code - I noticed it on your other RegExp code also.

 

You use:

 

(apply '(lambda (rlst / rlst item ro)
         ;; Clear reactors
         (setq rlst (vlr-reactors))
         (foreach item rlst
           (foreach ro (cdr item)
             (if (= "LTScale" (vlr-data ro))
               (vlr-remove ro)
             )
           )
         )
       )
      (list 1)
)

Why are you applying the lambda function to a redundant argument? Why not just have the lambda function evaluate on its own, hence:

 

(
 (lambda ( rlst )
   (foreach item rlst
     (foreach ro (cdr item)
       (if (= "LTSCALE" (vlr-data ro))
         (vlr-remove ro)
       )
     )
   )
 )
 (vlr-reactors)
)

Also, you use:

 

(VLR-Reaction-Set (vlr-sysvar-reactor "LTScale") :vlr-sysVarChanged 'LTScale:React)

Why do you use vlr-reaction-set and not just construct the reactor:

 

(vlr-sysvar-reactor "LTSCALE" (list (cons :vlr-sysVarChanged 'LTScale:React)))

Please don't think I am slating your code, I am just curious as to why you use these methods.

 

Lee

Link to comment
Share on other sites

I just do the following: PSLTSCALE=1 in all layouts, MSLTSCALE=1 in model tab, LTSCALE=whatever you prefer (throughout the entire DWG - one size fits all), in model tab CAnnoScale=something reasonable instead of 1:1. That way your linetypes adjust according to the scale applied - thus their dash lengths stay constant on the plotted paper. And due to the MSLTSCALE & CAnnoScale it appears correct even in Model space. No need to constantly set and reset LTSCALE as you had to with 2007 and before. You don't need to use Annotative objects to have this feature work for you, if you're scared of Annotative.

 

I understand what you are saying here but I don't quiet understand CANNOSCALE and I can't get the CANNOSCALE to change to anything but 1:1. Can you explain it to me please?

Link to comment
Share on other sites

I understand what you are saying here but I don't quiet understand CANNOSCALE and I can't get the CANNOSCALE to change to anything but 1:1. Can you explain it to me please?
The CAnnoScale is the current Annotation Scale name. This you change by setting the current scale using the pop-up in the bottom-right (status bar). Also each viewport would have its own CAnnoScale (which should match the VP Scale just next to it on the status bar).

 

Why are you applying the lambda function to a redundant argument? Why not just have the lambda function evaluate on its own, hence:
Because I'm lazy and just copy-pasted from somewhere else - actually quite "stupid" you're right :thumbsup:.
(VLR-Reaction-Set (vlr-sysvar-reactor "LTScale") :vlr-sysVarChanged 'LTScale:React)

Why do you use vlr-reaction-set and not just construct the reactor:

Mostly same reason. The other place I copied from is my ReactorTest.LSP file. And there I simply used this because it was easier to then use a Search-n-Replace to allow for all possible reactions - some of them seemed to fail if you use the direct reaction declaration. Don't know why, but I'm now used to this way, which hasn't given me problems yet.
Link to comment
Share on other sites

Actually the whole reason I'm using a lambda at all is to get rid of the variables after clearing the reactors. So though your code is the right way to go - the item and ro variables need to be localized inside the lambda. Otherwise the whole point of using it is lost.

Link to comment
Share on other sites

So though your code is the right way to go - the item and ro variables need to be localized inside the lambda. Otherwise the whole point of using it is lost.

 

I didn't think the symbols used by foreach loops and other such contructs needed to be localised - I thought they lost their value following the completion of the statement in which they are used.

Link to comment
Share on other sites

I didn't think the symbols used by foreach loops and other such contructs needed to be localised - I thought they lost their value following the completion of the statement in which they are used.

That's the impression I've always coded under.

Link to comment
Share on other sites

Maybe it's thus not necessary. I just don't trust that to happen. But as far as I'm concerned ... I was more worried about getting the code to actually do the work at the time ... didn't really care how the ancillaries were performing ... so it's much of a moot point really. And this all in order todo something which I highly disapprove of :roll:

 

Anyhow, I think we're way off topic here.

Link to comment
Share on other sites

You know what... one thing you need to consider... and almost always the case for our cad guys here.

when you think you did everything right (LTSCALES and the like) and the problem is still there?

 

just reload the Linetypes

 

Something like this

 ;; Credit to Alanjt ;;
(defun rlt ()
(command "_.-linetype" "_load" "*" "acad.lin")
(while (eq 1 (logand 1 (getvar 'cmdactive))) (command "")))

Edited by pBe
Typo (fat fingers sysndrome)
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...