stevesfr Posted May 21, 2010 Share Posted May 21, 2010 Greetings: In the earlier years of Acad it was possible to rename certain unused F-keys. In those years I assigned a command for a short lisp to an F-key. For example, upon entering LINE at the command line, one could hit the respective F-key (which contained the command for the short lisp) and the line would commence at the block insertion point if you picked anywhere on the block or its respective attributes. Now I would like to either know how to rename a useless F-key or combine my little lisp into another lisp, to that it would start the line at the insertion point of a picked block or its respective attribute(s). Cheers S Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 21, 2010 Share Posted May 21, 2010 You could call a LISP like this transparently: (defun c:AtInsertion ( / obj ) (if (setq obj (SelectifFoo (lambda ( x / o ) (setq o (vlax-ename->vla-object (cond ( (= (length x) 4) (car (last x)) ) ( (car x) ) ) ) ) (if (vlax-property-available-p o 'InsertionPoint) o ) ) "\nSelect Object: " ) ) (vlax-get obj 'InsertionPoint) ) ) (defun SelectifFoo ( foo str / sel x ) (while (progn (setq sel (nentsel str)) (cond ( (vl-consp sel) (if (not (setq x (foo sel))) (princ "\n** Invalid Object Selected **") ) ) ) ) ) x ) _non 'AtInsertion Quote Link to comment Share on other sites More sharing options...
stevesfr Posted May 21, 2010 Author Share Posted May 21, 2010 You could call a LISP like this transparently: (defun c:AtInsertion ( / obj ) (if (setq obj (SelectifFoo (lambda ( x / o ) (setq o (vlax-ename->vla-object (cond ( (= (length x) 4) (car (last x)) ) ( (car x) ) ) ) ) (if (vlax-property-available-p o 'InsertionPoint) o ) ) "\nSelect Object: " ) ) (vlax-get obj 'InsertionPoint) ) ) (defun SelectifFoo ( foo str / sel x ) (while (progn (setq sel (nentsel str)) (cond ( (vl-consp sel) (if (not (setq x (foo sel))) (princ "\n** Invalid Object Selected **") ) ) ) ) ) x ) _non 'AtInsertion Lee, this is what is happening here: If a block is picked, the line begins at the block insertion point. If an attribute of a block is picked, the line begins at the pick point. The following is the lisp I used to use: ;get insertion point of BLOCK by picking any attribute ! ; (DEFUN VV (/ PT1 PT2 PT5 PT6) (SETQ PT1 (ENTSEL "\nPick on BLOCK or ATTRIBUTE: ")) (SETQ ENT(ENTGET (CAR PT1))) (SETQ PT5 (CDR (ASSOC 10 ENT))) ) If you load this lisp, and after entering the line command, enter (VV) and pick the respective attribute, the line will begin at the block insertion point. This is very handy way of finding the block insertion point where there are many many point blocks clustered together with attributes of point#, desc, and elevations etc. Hope this is more informative for you. Cheers S Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 21, 2010 Share Posted May 21, 2010 From the description you gave, I was under the impression that you wanted to use the attribute insertion if the attribute was picked... Quote Link to comment Share on other sites More sharing options...
stevesfr Posted May 21, 2010 Author Share Posted May 21, 2010 From the description you gave, I was under the impression that you wanted to use the attribute insertion if the attribute was picked... Lee: your interpretation was correct. My bad. The last sentence should have read... line starts at the insertion point of the block wether the block or its attribute are picked. Sorry to all ! S Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 21, 2010 Share Posted May 21, 2010 No worries - you had the code already, but this may be better: (defun c:AtInsertion ( / obj ) (if (setq obj (SelectifFoo (lambda ( x ) (if (vlax-property-available-p (setq x (vlax-ename->vla-object x)) 'InsertionPoint ) x ) ) "\nSelect Object: " ) ) (trans (vlax-get obj 'InsertionPoint) (vlax-get obj 'Normal) 1) ) ) (defun SelectifFoo ( foo str / sel x ) (while (progn (setq sel (entsel str)) (cond ( (vl-consp sel) (if (not (setq x (foo (car sel)))) (princ "\n** Invalid Object Selected **") ) ) ) ) ) x ) Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 21, 2010 Share Posted May 21, 2010 Don't forget to translate your point to UCS. Very nice code Lee. Something else to play with... (defun c:AI (/ ss) (if (setq ss (ssget "_+.:E:S" '((0 . "INSERT")))) ((lambda (ins) (if (eq 1 (logand 1 (getvar 'cmdactive))) ins (command "_.line" "_non" ins) ) ) (trans (cdr (assoc 10 (entget (ssname ss 0)))) 0 1) ) ) ) Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 21, 2010 Share Posted May 21, 2010 Oh yeah, you can edit the F-keys in the CUI editor (called Accelerator Keys), but the easiest way is to just create an MNU file and load them from there. Also, if you use an MNL startup file with the same name as the MNU, it will automatically load on each startup. Here's clip from my AlanThompson.mnu file: ***MENUGROUP=[color=Red]AlanThompson[/color] ***TOOLBARS ***ACCELERATORS ["F1"]^C^CEXCHPROP ["F4"]^C^CIMPORTLAYERS ["F5"]^C^CPEDIT _M ["F6"]^C^CM2P ["F7"]^C^C'MATH [CONTROL+"Z"]'_zoom _p I load all my lisp routines and settings through a filed called AlanThompson.mnl When I get a new computer, all I have to do is type MenuLoad, load my AlanThompson.mnu file and I'm good to go. FYI, be sure to change the MENUGROUP name (colored in red). Quote Link to comment Share on other sites More sharing options...
stevesfr Posted May 21, 2010 Author Share Posted May 21, 2010 Oh yeah, you can edit the F-keys in the CUI editor (called Accelerator Keys), but the easiest way is to just create an MNU file and load them from there. Also, if you use an MNL startup file with the same name as the MNU, it will automatically load on each startup. Here's clip from my AlanThompson.mnu file: ***MENUGROUP=[color=red]AlanThompson[/color] ***TOOLBARS ***ACCELERATORS ["F1"]^C^CEXCHPROP ["F4"]^C^CIMPORTLAYERS ["F5"]^C^CPEDIT _M ["F6"]^C^CM2P ["F7"]^C^C'MATH [CONTROL+"Z"]'_zoom _p I load all my lisp routines and settings through a filed called AlanThompson.mnl When I get a new computer, all I have to do is type MenuLoad, load my AlanThompson.mnu file and I'm good to go. FYI, be sure to change the MENUGROUP name (colored in red). Thanks Alan and Lee, I'm off to ponder.... what is best.. I had given thought to somehow using something saved in USERS5 and then calling it up someway after LINE command to find block insertion point when touching either block or block attribute. But... cheers S Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 21, 2010 Share Posted May 21, 2010 Enjoy. Remember, if you use Lee's, the point needs to be translated to UCS, as it will give undesired results if you are not WCS. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 21, 2010 Share Posted May 21, 2010 Excellent point Alan - code updated. Thanks Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 21, 2010 Share Posted May 21, 2010 Excellent point Alan - code updated. Thanks You're welcome. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 21, 2010 Share Posted May 21, 2010 Updated to correct UCS Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 22, 2010 Share Posted May 22, 2010 Updated to correct UCS Did you make another update to the UCS? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 22, 2010 Share Posted May 22, 2010 Did you make another update to the UCS? Yes to allow for a change of normal. Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 22, 2010 Share Posted May 22, 2010 Yes to allow for a change of normal. Ahh, OK. ...... Quote Link to comment Share on other sites More sharing options...
SEANT Posted May 22, 2010 Share Posted May 22, 2010 Would a combination of techniques be more reliable when dealing with Inserts at odd orientations? See attached example. Forgive me for the mixing and matching previously posted code. (defun c:AtInsert2 ( / obj ) (if (setq obj (SelectifFoo (lambda ( x ) (if (vlax-property-available-p (setq x (vlax-ename->vla-object x)) 'InsertionPoint ) x ) ) "\nSelect Object: " ) ) (command "_.line" "_non"(trans (vlax-get obj 'InsertionPoint) 0 1)) ) ) (defun SelectifFoo ( foo str / sel x ) (while (progn (setq sel (entsel str)) (cond ( (vl-consp sel) (if (not (setq x (foo (car sel)))) (princ "\n** Invalid Object Selected **") ) ) ) ) ) x ) Inserts.dwg Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 22, 2010 Share Posted May 22, 2010 Let's mix it up even more... (defun c:AtInsert3 (/ obj) (if (setq obj (SelectifFoo (lambda (x) (if (vlax-property-available-p (setq x (vlax-ename->vla-object x)) 'InsertionPoint ) x ) ) "\nSelect Object: " ) ) ;; AJT begin edit ((lambda (ins) (if (eq 1 (logand 1 (getvar 'cmdactive))) ins (command "_.line" "_non" ins) ) ) (trans (vlax-get obj 'InsertionPoint) 0 1) ) ;; AJT end edit ) ) (defun SelectifFoo (foo str / sel x) (while (progn (setq sel (entsel str)) (cond ( (vl-consp sel) (if (not (setq x (foo (car sel)))) (princ "\n** Invalid Object Selected **") ) ) ) ) ) x ) Quote Link to comment Share on other sites More sharing options...
stevesfr Posted May 22, 2010 Author Share Posted May 22, 2010 Let's mix it up even more... (defun c:AtInsert3 (/ obj) (if (setq obj (SelectifFoo (lambda (x) (if (vlax-property-available-p (setq x (vlax-ename->vla-object x)) 'InsertionPoint ) x ) ) "\nSelect Object: " ) ) ;; AJT begin edit ((lambda (ins) (if (eq 1 (logand 1 (getvar 'cmdactive))) ins (command "_.line" "_non" ins) ) ) (trans (vlax-get obj 'InsertionPoint) 0 1) ) ;; AJT end edit ) ) (defun SelectifFoo (foo str / sel x) (while (progn (setq sel (entsel str)) (cond ( (vl-consp sel) (if (not (setq x (foo (car sel)))) (princ "\n** Invalid Object Selected **") ) ) ) ) ) x ) This is the best code yet !!! we are almost there !! when picking an attribute to begin the line, it does in fact start at the insertion point of the block, now if the second point or end of the line could likewise be picked from another attribute, (instead of entering 'AtInsert3), we would have the solution I was after ! thence continuing the line to the next attribute etc..... Bravo Alan !!! S Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 22, 2010 Share Posted May 22, 2010 (defun c:AtInsert3 (/ obj) (if (setq obj (SelectifFoo (lambda (x) (if (vlax-property-available-p (setq x (vlax-ename->vla-object x)) 'InsertionPoint ) x ) ) "\nSelect Object: " ) ) ;; AJT begin edit ((lambda (ins) (if (eq 1 (logand 1 (getvar 'cmdactive))) ins (command "_.line" "_non" ins "_non" (c:ATInsert3)) ) ) (trans (vlax-get obj 'InsertionPoint) 0 1) ) ;; AJT end edit ) ) (defun SelectifFoo (foo str / sel x) (while (progn (setq sel (entsel str)) (cond ( (vl-consp sel) (if (not (setq x (foo (car sel)))) (princ "\n** Invalid Object Selected **") ) ) ) ) ) x ) Of course, if that's all you wanted, this could be a lot simpler. 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.