shakuhachi Posted July 28, 2011 Share Posted July 28, 2011 I'm trying to call "EXPLAN" command on my lisp routine but I get an error message "Unknown command "EXPLAN". Press F1 for help.". Any help is kindly appreciated. (defun C:test (/ pt1 pt2) (setq pt1 (getpoint "\n Pick point: ")) (setq pt2 (getpoint "\n Pick X coordinate: ")) (command "ucs" "3" pt1 pt2 "") (command "explan" pause "" "c") (princ) ) Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted July 28, 2011 Share Posted July 28, 2011 why explan? this is express tool command. just enter plan: (command "_PLAN" "_C") maybe this will be helpful: (defun C:UU (/ *error* CMD OSM PT1) (defun *error* (msg) (if OSM (setvar 'OSMODE OSM)) ) (setq CMD (getvar 'CMDECHO) OSM (getvar 'OSMODE) ) (setvar 'OSMODE 512) (if (setq PT1 (getpoint "\n Select LEFT side of OBJECT which should be horizontal: ")) (progn (setvar 'CMDECHO 0) (command "_UCS" "_OB" PT1 "_PLAN" "_CURRENT") (setvar 'CMDECHO CMD) ) (princ "\n** Invalid point **") ) (if OSM (setvar 'OSMODE OSM)) (princ) ) (princ) k. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 28, 2011 Share Posted July 28, 2011 Since 'EXPLAN' is an Express Tools LISP program, you will need to call it as a function: (c:explan) Quote Link to comment Share on other sites More sharing options...
shakuhachi Posted July 28, 2011 Author Share Posted July 28, 2011 PLAN command zoom extends the drawing while EXPLAN keeps the current viewsize value of the current view and zoom center to the objects selected. Thanks for the code that you supplied but I need to pick the x coordinates as I'm working on a different view angle. Using "UCS" "OB" sometimes rotate the plan 180 degrees which I don't like. So picking 2 points as my x coordiantes and selecting the object to zoom center is the best way for me. why explan? this is express tool command.just enter plan: (command "_PLAN" "_C") maybe this will be helpful: Quote Link to comment Share on other sites More sharing options...
shakuhachi Posted July 28, 2011 Author Share Posted July 28, 2011 Thanks. It works Lee, but how can I automate that so I can select the object and then enter current. Just like (command "-la" "s" "layer1" ""). Want to skip extra steps. Since 'EXPLAN' is an Express Tools LISP program, you will need to call it as a function: (c:explan) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 28, 2011 Share Posted July 28, 2011 Perhaps modify this to suit your needs; (defun c:explan2 ( / _sscentre sc ss ) (defun _sscentre ( ss / i lst ll ur ) ;; Lee Mac (if ss (repeat (setq i (sslength ss)) (vla-getboundingbox (vlax-ename->vla-object (ssname ss (setq i (1- i)))) 'll 'ur) (setq lst (cons (vlax-safearray->list ll) (cons (vlax-safearray->list ur) lst))) ) ) (apply 'mapcar (cons '(lambda ( a b ) (/ (+ a b) 2.)) (mapcar '(lambda ( a ) (apply 'mapcar (cons a lst))) '(min max)) ) ) ) (setq sc (getvar 'VIEWSIZE)) (if (setq ss (ssget)) (vl-cmdf "_.plan" "_C" "_.zoom" "_C" (_sscentre ss) sc) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
shakuhachi Posted July 29, 2011 Author Share Posted July 29, 2011 Thanks Lee, but that didn't work. It just zoom center on the object selected. Sometimes it zoom out away from the object selected. I avoid selecting an entity for my coordinates for the x because sometimes the plan is rotated 180 degrees so I pick 2 points to be my x axis. I figured part of it but can't get the same viewsize so I just entered 4. How can I zoom on the object using the viewsize variable. (defun C:test (/ pt1 pt2) ;(setq cview (getvar 'viewsize)) [color="red"]<--[/color] (setq pt1 (getpoint "\n Pick point: ")) (setq pt2 (getpoint "\n Pick X coordinate: ")) (setq ent (entsel "\n Pick an object to center view : ")) (command "_.ucs" "3" pt1 pt2 "") (command "_.plan" "c") (command "_.zoom" "ob" ent "") (command "_.zoom" 4)[color="red"]<<-- change to cview[/color] (princ) ) Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted July 29, 2011 Share Posted July 29, 2011 probably you want something like this: (defun C:test (/ cview pt1 pt2) (setq cview (getvar 'viewsize)) (setq pt1 (getpoint "\n Pick point: ")) (setq pt2 (getpoint "\n Pick X coordinate: ")) (command "_.ucs" "3" (trans pt1 1 0) (trans pt2 1 0) "") (command "_.plan" "c") (command "_.zoom" "_c" (trans pt1 0 1) cview) (princ) ) Lee could you help with trans? i always have a problem with this. it works fine only when we start from WCS. thx kruuger Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 29, 2011 Share Posted July 29, 2011 Try: (defun C:test ( / cview pt1 pt2 ptw ) (setq cview (getvar 'viewsize)) (if (and (setq pt1 (getpoint "\n Pick point: ")) (setq pt2 (getpoint "\n Pick X coordinate: ")) (setq ptw (trans pt1 1 0)) ) (command "_.ucs" "3" pt1 pt2 "" "_.plan" "c" "_.zoom" "_c" (trans ptw 0 1) cview) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted July 29, 2011 Share Posted July 29, 2011 HA! BINGO thank you have a good weekend k. EDIT: this one should be a little comfortable (defun C:test ( / cview pt1 pt2 mp ) (setq cview (getvar 'viewsize)) (if (and (setq pt1 (getpoint "\n Pick point: ")) (setq pt2 (getpoint "\n Pick X coordinate: ")) (not (equal pt1 pt2)) (setq mp (trans (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2.0)) 1 0)) ) (command "_.ucs" "3" pt1 pt2 "" "_.plan" "c" "_.zoom" "_c" (trans mp 0 1) cview) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 29, 2011 Share Posted July 29, 2011 You too mate Quote Link to comment Share on other sites More sharing options...
shakuhachi Posted July 29, 2011 Author Share Posted July 29, 2011 Thanks guys. It works and much better than I anticipated. Save me a click on the mouse. Love you all. LOL Quote Link to comment Share on other sites More sharing options...
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.