TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Brick_top on April 20, 2016, 09:54:15 AM
-
Hi there.
question is in the title
I'm using a routine that loads and unloads images according to coordinates inside some polygons.
But I want to cycle through some images by pressing a key.
thanks
-
Grread will not return a point and a character code at the same time.
But you can create code that stores point values while waiting for keyboard input:
(defun test
( / doneP gr pt ret
) )
)
)
)
)
ret
)
-
thanks a lot man.. this stuff is a bit over my head.
I'm going to try to incorporate it into my code.
I was almost making it work with a workaround, but just couldn't write an *error* function for when I hit Esc
this is the part where I almost got it to work
(while (setq gr (grread T))
(setq imagedict (dictsearch (namedobjdict) "ACAD_IMAGE_DICT")
imagefiles (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 3 (car x))) imagedict))
gr_lst (cons gr gr_lst)
);setq
(if
(or
(= 2 (car gr))
(= 11 (car gr))
);or
(progn
(setq gr2 (chr (cadr gr))
gr (nth 1 gr_lst)
);setq
);progn
);if
I was storing all the grread input into the gr_lst list so that when I press a key it would define a variable for it and would retrieve the coordinate prior to the key press, because the routine would stop whenever the gr variable was not a coordinate.
the problem now was how to write a proper *error* function
edit - by the way how do you create that code section with the color?
-
edit - by the way how do you create that code section with the color?
See: https://www.theswamp.org/index.php?topic=48309.0
-
I am not sure how you want to employ your *error* function.
If you want to 'catch' escaping out of the 'grread' loop I would suggest something like this:
(defun c:test2
( / doneP gr pt ret
) )
)
)
)
)
)
)
)
)
(princ "\nEscape has been pressed ") ; ...
; ...
)
; ...
; ...
)
)
)
-
In your code you are defining imagedict and imagefiles inside the while loop. Since these values do not change it would make more sense to define them before starting the loop.
-
hi roy thanks again for your help. I never used those vl-catch functions I'll have to get used to them.
regarding my variables "imagedict" and "imagefiles" hopefully I'm not defining them in vain. Sorry to put that code in there without a context.
In the function I'm trying to write I'm moving the cursor over some polygons and while it is inside a polygon it loads a "corresponding" image. if then I move to another polygon it has to load another image and unload the previous.
thats why I'm doing the dictionary search because if I'm not mistaken as I load an image there is an entry written to the dictionary, and when I unload an image the entry gets removed right?
thank you!
edit - sorry if my english sounds strange
-
May I suggest this thread: https://www.theswamp.org/index.php?topic=27900.msg334708#msg334708 (https://www.theswamp.org/index.php?topic=27900.msg334708#msg334708)
-
oops... :o I knew I should have done a search before posting
thank you for your input :)
-
regarding my variables "imagedict" and "imagefiles" hopefully I'm not defining them in vain. Sorry to put that code in there without a context.
No, the mistake is mine, I should not have made assumptions regarding your code. Scratch my post #5.
-
hi roy, I tried your test functions and if I'm using them correctly they exit withouth an error when I press a key.
I should have been more clear.
What I'm trying to do is for the function to continue while I don't press "esc"
and keep returning the pointer coordinates and key presses.
my problem is that my function "freezes" when I press esc.
edit - I'm reading the topic suggested by ymg and I might find my answer there.
-
What I'm trying to do is for the function to continue while I don't press "esc"
and keep returning the pointer coordinates and key presses.
...
my problem is that my function "freezes" when I press esc.
This is still not clear. What should happen if Esc is pressed? You don't want the function to continue, but you don't want the function to stop (freeze) either.
If you want the function to continue after 'normal' key input, all you have to do is completely remove the doneP variable from the c:Test2 function in one of my previous posts.
-
lets see if I say it right this time :laugh:
I want the function to continue after normal key input (if there is a key input I need a coordinate aswell), and to exit without freezing when i press "esc"
-
I'm sorry... I should just study more :oops:
edit - ok now I get it.
when removing the doneP variable I get a key and a coordinate in the ret variable
thanks a lot, sorry for all the trouble
-
Hi there roy! just wanted to tell you that I got what I wanted working!
thanks again for all the help! and to ymg aswell
-
Hi there roy! just wanted to tell you that I got what I wanted working!
thanks again for all the help! and to ymg aswell
Excellent! :-)
-
I'm so stoked about this! just added some keys to zoom in and out! so cool! :yes: