TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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?
-
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 ?
-
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???
-
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.
-
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?"
-
Wouldn't the bright white screen throw up a "red flag?"
that's just what I was thinking :shock:
-
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.
-
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.
-
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.
-
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.
-
I do understand as I have the same issues occasionally.
-
Thanks Daron.
Any help is greatly appreciated!
-
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.)
-
Looks Greek to me as i am not familiar with creating reactors.
-
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?
(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)
)
-
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.
(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.
-
Do you copy this code to a vlisp editor & save as a vlx file & then appload?
-
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).
-
that's pretty cool
-
Of course it is?! ...J/K, Glad you like it.
-
sorry, that was me...forgot to login (wasn't being sarcastic)
-
Oh, i know. The thought of you being sarcastic didnt even cross my mind.
-
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
-
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!
-
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:
-
*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?!
-
...I think its MircoCrappy that is rotting my brain!?
-
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.
(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))))
-
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?
-
Holly cow man?! Your killing me! ...I dont have the first idea. Ill have to think that one over a bit.
-
Don't lie in bed tonight counting popcorn on the ceiling trying to figure it out.
thanks for ur help :)
-
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.
-
Thanks for all of your help
-
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.
-
No problem.
Of course it works Daron. (I wouldnt have posted it if it didnt ya boob. :lol:)
-
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.
-
Ohhhhoo, I got cha.
-
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.
-
Got some help on Autodesk forum here it is:
Thanks to all who helped out
;;;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)
-
"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.
-
"CVPORT" ...That is it!!! Thats the variable i was tryin to think of last night!!!! w00t!
-
Who did that?
Jürg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch
-
Yep, that's the guy who wrote it.
Jürg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch