TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: bman on September 07, 2004, 08:16:24 PM

Title: Change crosshair color when switched to paperspace
Post by: bman on September 07, 2004, 08:16:24 PM
How would i go about creating a reactor that would change the crosshairs to red everytime you're in paperspace & switch it back to white when in modelspace or tilemode 1?...or switch the background color from black to grey?
Title: Change crosshair color when switched to paperspace
Post by: Kerry on September 07, 2004, 08:37:23 PM
You can use the AcadPreferencesDisplay Object Properties.

explicitly
(vla-put-GraphicsWinLayoutBackgrndColor ...
(vla-put-LayoutCrosshairColor ...

  etc, etc,

A thought though.Are you aware these can be set from
 Options-> Display->Colors....

set and forget, and save the reactor processing ?
Title: Change crosshair color when switched to paperspace
Post by: bman on September 07, 2004, 09:05:17 PM
yeah i'm aware of the
Options-> Display->Colors....
The only problem is that the colors don't change when you're in pspace vs. mspace. I have two people that recently switched to using paperspace & they're continously drawing half of the entities in pspace & the other half in model. I figured if i could get the crosshairs to change to red when in paperspace that would throw up a red flag for them to switch to mspace. What's the best way to achieve this....using reactors???
Title: Change crosshair color when switched to paperspace
Post by: Kerry on September 07, 2004, 10:27:36 PM
Quote from: bman
yeah i'm aware of the
Options-> Display->Colors....
The only problem is that the colors don't change when you're in pspace vs. mspace. I have two people that recently switched to using paperspace & they're continously drawing half of the entities in pspace & the other half in model. I figured if i could get the crosshairs to change to red when in paperspace that would throw up a red flag for them to switch to mspace. What's the best way to achieve this....using reactors???


funny, mine does.

and if they switch from paperspace to modelspace when in a layout, the X-Y Icon displays in the work area.

I would have another look before you start to think about adding reactors/event handling.
Title: Change crosshair color when switched to paperspace
Post by: Dommy2Hotty on September 07, 2004, 10:38:57 PM
Quote from: bman
I figured if i could get the crosshairs to change to red when in paperspace that would throw up a red flag for them to switch to mspace.


Wouldn't the bright white screen throw up a "red flag?"
Title: Change crosshair color when switched to paperspace
Post by: hendie on September 08, 2004, 03:20:31 AM
Quote from: Dommy2Hotty
Wouldn't the bright white screen throw up a "red flag?"


that's just what I was thinking  :shock:
Title: Change crosshair color when switched to paperspace
Post by: daron on September 08, 2004, 08:20:28 AM
It would if you left it as a bright white screen. Then again even if you do, it doesn't let the user know whether or not he's in a viewport or not. I do the same thing, where in the model tab, my crosshairs are green and when in any of the layout tabs, my crosshairs are red. If I should activate any of the viewports, the color of the crosshair is still red. What bman is looking for is the crosshairs to be changed to the model tab color while in a viewport through a layout tab. I kind of like the idea he's coming up with. As far as further development goes, it would be good if the crosshairs were changed to a color based on if the current viewport were locked or unlocked.
Title: Change crosshair color when switched to paperspace
Post by: bman on September 08, 2004, 08:52:39 AM
I've changed the crosshairs under
Options>Display>Color>Layout Tabs Pointer to red.
When in tilemode 0, I switch back & forth between between pspace & mspace the crosshairs stay red. When in tilemode 0, I was thinking that if the crosshairs changed colors when switching from vport modelspace to pspace then hopefully that would turn on a light bulb.

The problem is that others here turn on all the layers & switch to tilemode 0 & freeze layers in the current vport & edit the plan sheets in each individual vport. I keep getting interupted quite often on a daily basis due to "Lost in Paperspace". I use scripts & layer manager to manipulate plans & switch to pspace to just plot the dwg so i don't have this problem.

I know some sort of standards would fix this problem but no one here is willing to enforce them. We have ten different people doing things ten different ways.
Title: Change crosshair color when switched to paperspace
Post by: daron on September 08, 2004, 08:56:39 AM
bman, I feel your pain. We're going through similar problems here. Yours is far worse though. As far as your last post, I believe I do understand the line of thought you're after. I'll try to look into it using what Kerry offered up.
Title: Daron hit the nail on the head
Post by: bman on September 08, 2004, 09:03:14 AM
It would help those who do their editing within the viewports if the crosshairs changed colors when switching from mspace to pspace so that things don't get unintentionally placed in pspace.
Title: Change crosshair color when switched to paperspace
Post by: daron on September 08, 2004, 09:06:45 AM
I do understand as I have the same issues occasionally.
Title: Change crosshair color when switched to paperspace
Post by: bman on September 08, 2004, 09:07:24 AM
Thanks Daron.
Any help is greatly appreciated!
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 08, 2004, 09:11:27 AM
Kerry gave it to ya already. Didnt he? He told you some of the key functions to use. (Thats prety much it, after that is just misc "setup" code.)
Title: Change crosshair color when switched to paperspace
Post by: bman on September 08, 2004, 09:22:26 AM
Looks Greek to me as i am not familiar with creating reactors.
Title: Change crosshair color when switched to paperspace
Post by: daron on September 08, 2004, 09:23:48 AM
Well, here's the start, but as you'll notice I had to change the value of the variant for the color code. For some reason it outputs as a 19 variant value, which doesn't seem to exist. Now, the value in the variant is, on my cpu, 65280?!? Anybody know how to make color sense of that?
Code: [Select]
(setq $acad (vlax-get-acad-object)
      $doc  (vla-get-activedocument $acad)
      )
(setq acpref (vla-get-preferences $acad)
      acdisp (vla-get-display acpref)
      aclcco (vlax-variant-change-type (vla-get-LayoutCrosshairColor acdisp) 5)
      )
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 08, 2004, 09:33:26 AM
lol, Just for example:
Here is a small reactor lisp that will react to the "line" command. To cancel the reactor just issue a "SAVE" command.

This is a small demonstration for using Reactors to react to a command.
Code: [Select]
(vl-load-reactors)
(vlr-command-reactor nil '((:vlr-CommandWillStart . StartCommand)))
(defun StartCommand (calling-reactor startcommandinfo / thecommandstart)
  (setq thecommandstart (nth 0 startcommandInfo))
  (cond
    ((= thecommandstart "LINE")
     (theswamp)
     )
    ((= thecommandstart "SAVE")
     (vlr-remove-all :vlr-command-reactor)
     )
    ((= thecommandstart "QSAVE")
     (vlr-remove-all :vlr-command-reactor)
     )
    )
  )
(defun theswamp ()
  (alert "Please wait unitll direct you to TheSwamp...")
  (startapp "explorer" "http://www.theswamp.org/phpBB2/")
  (alert "You may now continue with your line.
         To cancle this reactor use the save command.")
 (princ)
)


When i get some time, ill see if i can help out more.
Title: Change crosshair color when switched to paperspace
Post by: bman on September 08, 2004, 09:53:58 AM
Do you copy this code to a vlisp editor & save as a vlx file & then appload?
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 08, 2004, 10:02:07 AM
Me? No.

Cut and paste it into your command line and issue the line command. (type "l" <sapce bar>) and then you will get an alert box, then an explorer window will open to the swamp. Then issue a save command to cancle it. (ctrl+s).
Title: Change crosshair color when switched to paperspace
Post by: Anonymous on September 08, 2004, 10:06:09 AM
that's pretty cool
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 08, 2004, 10:13:47 AM
Of course it is?! ...J/K, Glad you like it.
Title: Change crosshair color when switched to paperspace
Post by: bman on September 08, 2004, 10:32:54 AM
sorry, that was me...forgot to login (wasn't being sarcastic)
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 08, 2004, 10:44:00 AM
Oh, i know. The thought of you being sarcastic didnt even cross my mind.
Title: Change crosshair color when switched to paperspace
Post by: SMadsen on September 08, 2004, 11:00:37 AM
Quote from: Se7en
Me? No.


No, copy and paste to VIM, then save it in VIM with the extension .007, then setup VIM to colorcode lsp files, then write a WSH script to load .007 files in AutoCAD, then open VIM and ...

ok ok, that was sarcasm  :P

Good job Se7en. I think I'll put that alert into all my VI.. ummm lsp files
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 08, 2004, 11:41:44 AM
Quote from: SMadsen
No, copy and paste to VIM, then save it in VIM with the extension .007, then setup VIM to colorcode lsp files, then write a WSH script to load .007 files in AutoCAD, then open VIM and ...

ok ok, that was sarcasm  :P

Good job Se7en. I think I'll put that alert into all my VI.. ummm lsp files
*blink* ... Ahhh!? *sigh*  

Pay no attention to him everybody, that is how he would do it. (*Se7en whispers* Cause he’s not that good with AutoLisp, so he has to do things five times.)

Stig, i thought you would like VIM because the guy that wrote it is Dutch. (Support those fellow Europeans.) --Ok, those were some bad jokes. ...darn it, I’m loosing the ability to make smartass remarks.

BTW, I like that extension of .007 ...*wink* lmao!
Title: Change crosshair color when switched to paperspace
Post by: SMadsen on September 08, 2004, 11:52:35 AM
Hehe

Those dutchies are usually pretty good with computers but you know there has to be an exception to every rule .. I think VIM is it  :twisted:
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 08, 2004, 11:58:53 AM
*choke* ...Ahhhh! Darnit!! Stig has got me on the fricken run here. I cant think of anything witty to say.
*Se7en starts shaking*
Stig your a big dummy!
...grrr!

Awe crap?!
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 08, 2004, 12:01:08 PM
...I think its MircoCrappy that is rotting my brain!?
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 08, 2004, 05:09:31 PM
Sorry, I had a meeting at lunch and i had another "thing" i needed to get done. But i whiped up some code for ya; Give this a try and let me know if it works alright for ya.

Code: [Select]
(vl-load-reactors)
(vlr-miscellaneous-reactor
   nil '((:vlr-layoutSwitched . ChangeLayoutCrosshairColor-Red)))
(defun ChangeLayoutCrosshairColor-Red (calling-reactor info /)
   (if (not (eq (car info) "Model"))
     (vla-put-LayoutCrosshairColor
       (vla-get-Display (vla-get-Preferences (vlax-get-acad-object)))
       (vlax-make-variant 255 vlax-vbLong))))
Title: Change crosshair color when switched to paperspace
Post by: bman on September 08, 2004, 07:46:51 PM
I think ur on the right path... that changed the crosshairs to red when switching to pspace. How do you get it to change to white when you click in a viewport?
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 08, 2004, 08:17:06 PM
Holly cow man?! Your killing me! ...I dont have the first idea. Ill have to think that one over a bit.
Title: Change crosshair color when switched to paperspace
Post by: bman on September 08, 2004, 08:29:29 PM
Don't lie in bed tonight counting popcorn on the ceiling trying to figure it out.
thanks for ur help :)
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 08, 2004, 10:46:07 PM
Well the code isnt really a problem, its just that i dont think i know of a way to test to see if the user is in "floating model space". Cha know?

...Not to mention that i seriously doubt that there is a "viable" way to react to that.

Well that is a thunk-er but i dont think i can help you anymore. (that is about the best i can offer you. Sorry.) Let's see if someone else thinks of a way.
Title: Change crosshair color when switched to paperspace
Post by: bman on September 09, 2004, 08:08:01 AM
Thanks for all of your help
Title: Change crosshair color when switched to paperspace
Post by: daron on September 09, 2004, 08:16:19 AM
Well, if this code that se7en posted works, I'll definately look into seeing what I can come up with, since I could use it myself.
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 09, 2004, 08:25:49 AM
No problem.

Of course it works Daron. (I wouldnt have posted it if it didnt ya boob. :lol:)
Title: Change crosshair color when switched to paperspace
Post by: daron on September 09, 2004, 08:43:19 AM
I didn't mean work as in it wouldn't. I meant works in if I could make it work for the thought I've got in mind.
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 09, 2004, 08:45:57 AM
Ohhhhoo, I got cha.
Title: Change crosshair color when switched to paperspace
Post by: daron on September 09, 2004, 10:31:18 AM
I was looking a bit and the only thing I could find that would tell you if you were in a viewport or not would be to look at the customscale property. In paperspace it appears to be 1.0, but in mspace not 1.0, unless of course you are scaled to 1:1.
Title: Change crosshair color when switched to paperspace
Post by: bman on September 09, 2004, 11:45:50 AM
Got some help on Autodesk forum here it is:
Thanks to all who helped out

Code: [Select]
;;;Changes the crosshairs to Red when switching to pspace
;;;changes back to white when in current vport or modelspace
;;;To Install, change the name of this file to AcadDOC.lsp & add to the acad support directory
 
(vl-load-com)

(or Me:Svr
 (setq Me:Svr (VLR-SysVar-Reactor
               nil
              '((:VLR-sysVarChanged . MeChangeCrosshairColor))
              )
 )
)  
(or Me:Dmr
 (setq Me:Dmr (vlr-DocManager-reactor
               nil
              '((:VLR-documentToBeDestroyed . MeDoCloseStuff))
              )
 )
)

(defun MeDoCloseStuff (Rea Arg)
 (mapcar 'VLR-remove (list Me:Svr Me:Dmr))
 (setq Me:Dmr nil
       Me:Svr nil
 )
 (princ)
)

(defun MeChangeCrosshairColor (Rea Arg / AcaDsp AcaObj LayBco)
 (if (vl-position (car Arg) '("CVPORT"))
  (progn
   (setq AcaObj (vlax-get-acad-object)
         AcaDsp (vla-get-Display (vla-get-Preferences AcaObj))
         LayBco (vlax-variant-value
                 (vlax-variant-change-type
                  (vla-get-GraphicsWinLayoutBackgrndColor AcaDsp)
                  vlax-vbLong
                 )
                )
   )
   ;
   ; Color list:
   ;        0 = Black
   ;      255 = Red
   ;    65535 = Yellow
   ;    65280 = Green
   ; 16776960 = Cyan
   ; 16711680 = Blue
   ; 16711935 = Magenta
   ; 16777215 = White
   ; Set the cursor color to the appropriate value:
   ;
   (vla-put-LayoutCrosshairColor
    AcaDsp
    (if (= (getvar "CVPORT") 1)
     255 ;Cursor color in Paperspace
     (MeInvGreyCol LayBco)
    )
   )
  )
 )
 (princ)
)

(defun MeInvGreyCol (Col)
 (boole 6
  (*
   (*
    (/
     (/
      (+ (logand Col 255) (logand (/ Col 256) 255) (logand (/ Col 65536) 255))
      3
     )
     128
    )
    255
   )
   65793
  )
  16777215
 )
)

(princ)
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 09, 2004, 01:13:44 PM
"VLR-SysVar-Reactor" ...huh?! cool!

Who did that? (some of that code style looks familiar. but the formatting looks...?) There are some prety cool lil tricks in there. You should thank whoever did that alot; they taught some prety cool lessons.
Title: Change crosshair color when switched to paperspace
Post by: JohnK on September 09, 2004, 01:16:28 PM
"CVPORT" ...That is it!!! Thats the variable i was tryin to think of last night!!!! w00t!
Title: Change crosshair color when switched to paperspace
Post by: Mark on September 09, 2004, 01:44:16 PM
Quote from: Se7en
Who did that?

Jürg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch
Title: Change crosshair color when switched to paperspace
Post by: bman on September 09, 2004, 02:04:50 PM
Yep, that's the guy who wrote it.

Jürg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch