MJLM Posted September 26, 2018 Posted September 26, 2018 (edited) I am trying to make my lisp routine transparent. The routine just calls the top orientation by sizing the view window by two points. (defun test (/ cp wcp1 wcp2 ss) ; top orientation (setq cp (getvar "viewctr")) (setq wcp1 (list (- (car cp) 5) (- (cadr cp) 5) (caddr cp))) (setq wcp2 (list (+ (car cp) 5) (+ (cadr cp) 5) (caddr cp))) (setq ss (ssget "_C" wcp1 wcp2)) (command "_.view" "top") (command "_.zoom" "O" ss "") (princ) ) I found this method to make it transparent (vlax-add-cmd "test" 'test "test" ACRX_CMD_TRANSPARENT) but after some research I realized (correct me if I am wrong) that this could not be transparent as long a 'command' call is invoked within the routine. Is it possible to make it transparent somehow after all? If not, how could I modify the code to get rid of the 'command' calls for that particular code? Thank you for any suggestions. Edited September 26, 2018 by MJLM Quote
Grrr Posted September 26, 2018 Posted September 26, 2018 Hi, Before saying anything related to your question... are you aware that t is a protected symbol, and it stands for true in vanilla lisp? Quote
MJLM Posted September 26, 2018 Author Posted September 26, 2018 Yes I am aware of it but nevertheless it doesn't make any difference. Lets just change 't' to 'test'. Quote
David Bethel Posted September 26, 2018 Posted September 26, 2018 Have you tried (defun c:test () AFAIK, transparency is only available for command functions. Quote
MJLM Posted September 27, 2018 Author Posted September 27, 2018 (edited) Yes I tried. it doesn't make any difference. The whole idea of the vlax-add-cmd is to make your routines behaving as standard Autocad command functions. So sould I stop dreaming about transparency of my functions? Edited September 27, 2018 by MJLM Quote
David Bethel Posted September 27, 2018 Posted September 27, 2018 https://www.cadtutor.net/forum/topic/6354-is-it-possible/ Might help Quote
lido Posted September 27, 2018 Posted September 27, 2018 1. Rename (defun test (/ .... with (defun c:test (/.... 2. Use: Command: line Command: (c:test) ..... Quote
hanhphuc Posted September 27, 2018 Posted September 27, 2018 (edited) 20 hours ago, MJLM said: how could I modify the code to get rid of the 'command' calls for that particular code? hi, my suggestion would be using activeX method (vl-load-com) (setq *acDoc* (vla-get-activedocument (vlax-get-acad-object))) (defun test (/ wc ss vw) (if (and (setq wc (mapcar ''((f) (mapcar f (getvar "viewctr") '(5. 5. 0.))) '(- +)) ss (apply 'ssget (cons "_C" wc)) ) (setq vw (vla-get-activeviewport *acdoc*)) ) (progn (vlax-put vw 'direction '(0. 0. 1.)) (vla-put-activeviewport *acdoc* vw) (apply 'vla-zoomwindow (cons (vlax-get-acad-object) (mapcar 'vlax-3d-point wc))) ) ) (princ) ) (vlax-add-cmd "test" 'test "test" 1) ;reference: Dev.Documentation ;ACRX_CMD_MODAL (0) Command cannot be invoked while another command is active. ;ACRX_CMD_TRANSPARENT (1) Command can be invoked while another command is active. ;ACRX_CMD_USEPICKSET (2) When the pickfirst set is retrieved it is cleared within AutoCAD. ; Command will be able to retrieve the pickfirst set. Command cannot retrieve or set grips. ;ACRX_CMD_REDRAW (4) Did you put a prefix 'quote mark (apostrophe) upon issuing transparent command? Quote Command: LINE LINE Specify first point: Specify next point or [Undo]: 'test Regenerating model. >>Command: >>Command: Resuming LINE command. or Quote Command: LINE LINE Specify first point: Specify next point or [Undo]: (test) ... ... I recall a similar 'transparent' like ortho 45 but not using 'vlax-add-cmd' , just by calling function which symbol to be included parentheses example : (test) (dd) etc.. Edited September 27, 2018 by hanhphuc changed '(+ -) to '(- +) Quote
MJLM Posted September 27, 2018 Author Posted September 27, 2018 Well, just as I though, by eliminating the 'command' call it worked. Thank you for the activeX version. One little problem though, the (apply 'vla-zoomwindow (cons (vlax-get-acad-object) (mapcar 'vlax-3d-point wc))) at the end does not work well. It zooms to an other area, like being shifted upwards. Any idea? Quote
hanhphuc Posted September 27, 2018 Posted September 27, 2018 50 minutes ago, MJLM said: One little problem though, at the end does not work well. It zooms to an other area, like being shifted upwards. Any idea? sorry minimal tested (setq wc (mapcar ''((f) (mapcar f (getvar "viewctr") '(5. 5. 0.))) '(+ -))) 1st corner should be lower than upper corner, i.e: change this '(+ -) to '(- +) ? another, if you wanna zoom multiple objects? IMO boundingbox function may help (command "_.zoom" "O" ss "") as long as activeX suggestion solved the issue, the rest let you DIY Quote
MJLM Posted September 27, 2018 Author Posted September 27, 2018 No, actually that's not it. I personally changed the code to this as to me is a bit more user friendly. (setq winsz 5.0) (if (and (setq cp (getvar "viewctr")) (setq wcp1 (mapcar '- cp (list winsz winsz winsz))) (setq wcp2 (mapcar '+ cp (list winsz winsz winsz))) (setq ss (apply 'ssget (cons "_C" (setq wc (list wcp1 wcp2))))) (setq vw (vla-get-activeviewport *acdoc*)) ; *acdoc* is defined elsewhere together with vl-load-com command ) (progn (vlax-put vw 'direction '(0.0 0.0 1.0)) (vla-put-activeviewport *acdoc* vw) (apply 'vla-zoomwindow (cons (vlax-get-acad-object) (mapcar 'vlax-3d-point wc))) ) ) It seems that the (mapcar 'vlax-3d-point wc) at the end produces the wrong point. Quote
hanhphuc Posted September 27, 2018 Posted September 27, 2018 41 minutes ago, MJLM said: at the end produces the wrong point are you working in difference ucs? it seems more like drafting issue? could you elaborate what should be correct points etc , ppl following here could assist you too 21 hours ago, MJLM said: The routine just calls the top orientation by sizing the view window by two points. Quote
MJLM Posted September 27, 2018 Author Posted September 27, 2018 Well it works. I tried to some other models and it seems to be working as expected. However, although now I can have a transparent command, this method is greatly depended on an arbitrary value of variable 'winsz' and therefore is not working quite as well as the other method, that is (command "_.zoom" "O" ss "") Is there a vla method to zoom by objects? Quote
Grrr Posted September 27, 2018 Posted September 27, 2018 26 minutes ago, MJLM said: (command "_.zoom" "O" ss "") Is there a vla method to zoom by objects? You can use (vla-ZoomWindow acadObj point1 point2) in conjunction with LM:ssboundingbox. Quote
MJLM Posted September 28, 2018 Author Posted September 28, 2018 Intersting. Thanks. I will have a look later today and let you know how it works. Quote
MJLM Posted September 28, 2018 Author Posted September 28, 2018 So I tried the routine of Lee and it works well. It satisfies my goal. However the perfect way (I believe) would be to get the two bounding points of the screen view rather through a bounding box of some selection set. Would it be possible to get the same list as Lee does with just the low right and upper left points of the current screen regardless of ss? The vla-getboundingbox seems to be working with entities only. Quote
Grrr Posted September 28, 2018 Posted September 28, 2018 9 minutes ago, MJLM said: Would it be possible to get the same list as Lee does with just the low right and upper left points of the current screen regardless of ss? Not sure if I follow you, but you can try another subfoo from Lee (source thread) : ;; Viewport Extents - Lee Mac ;; Returns two WCS points describing the lower-left and ;; upper-right corners of the active viewport. (defun LM:ViewportExtents ( / c h v ) (setq c (trans (getvar 'viewctr) 1 0) h (/ (getvar 'viewsize) 2.0) v (list (* h (apply '/ (getvar 'screensize))) h) ) (list (mapcar '- c v) (mapcar '+ c v)) ) Quote
MJLM Posted September 29, 2018 Author Posted September 29, 2018 Thanks. I finally came up with this. Not perfect but works decently and without being depended on any arbitrary fixed value rather what's currently on the screen. And above all, it"s transparent. (defun t (/ winsz cp wcp1 wcp2 ss_view wc bounding_list ss_bb) ; top orientation (init_autil) (setq bounding_list (vpe)) (cond ((setq ss_bb (ssget "_W" (car bounding_list) (cadr bounding_list))) (setq bounding_list (ssboundingbox ss_bb)) ) ((setq ss_bb (ssget "_C" (car bounding_list) (cadr bounding_list))) (setq bounding_list (ssboundingbox ss_bb)) ) (t (setq bounding_list (vpe))) ) (setq vw (vla-get-activeviewport *acdoc*)) ; *acdoc* defined elsewhere (vlax-put vw 'direction '(0.0 0.0 1.0)) (vla-put-activeviewport *acdoc* vw) (apply 'vla-zoomwindow (cons (vlax-get-acad-object) (mapcar 'vlax-3d-point bounding_list))) (end_autil) (princ) ) where 'vpe' is the LM:ViewportExtents of Lee Mac's as above. Quote
Recommended Posts
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.