martymoose Posted November 17, 2008 Share Posted November 17, 2008 I have a block library of several hundred blocks. Many of these blocks I insert into my drawings (one at a time) and snap to lines already in my drawing. As I insert and snap to these lines, I need the block to take the layer of the line I am snaping to. I am just unsure how to accomplish this. Recently, after I insert the block, I will follow up with a 'matchproperties' command, but it would be nice to do this in one click. It would save me a lot of time!! All my blocks were created on layer 0, so they can take the properties of these lines. I usually snap to the nearest or endpoint. I appreciate your help. Quote Link to comment Share on other sites More sharing options...
borgunit Posted November 17, 2008 Share Posted November 17, 2008 Vb or lisp? Quote Link to comment Share on other sites More sharing options...
martymoose Posted November 17, 2008 Author Share Posted November 17, 2008 lisp would be great. Quote Link to comment Share on other sites More sharing options...
lpseifert Posted November 17, 2008 Share Posted November 17, 2008 quick and dirty. Can be revised to suit your needs (defun c:test (/ oldecho oldlayer ent p1 entlst layname blkname) (vl-load-com) ;======ERROR TRAP======= (setq temperr *error* ;store *error* *error* errortrap ;re-assign *error* oldecho (getvar "cmdecho") ;store variables as needed oldlayer (getvar "clayer") ) ;======ERROR TRAP======= (setq oldlayer (getvar "clayer") oldecho (getvar "cmdecho") ent (entsel "\nPick insert point on line for block: ") p1 (vlax-curve-getclosestpointto (car ent) (cadr ent)) entlst (entget (car ent)) layname (cdr (assoc 8 entlst)) blkname (getstring "\nEnter block name: ") );setq (setvar "clayer" layname) (initdia) (command "-insert" blkname p1 "" "") ;(while (> (getvar 'CmdActive) 0) (command pause)) (setvar "clayer" oldlayer) (setvar "cmdecho" oldecho) (princ) );defun ;======ERROR TRAP======= (defun errortrap (msg) (setvar "cmdecho" oldecho) ;restore variables (setvar "clayer" oldlayer) (setq *error* temperr) ;restore *error* (prompt "\nError or break encountered...Resetting System Variables ") ;inform user (princ) );defun ;======ERROR TRAP======= Quote Link to comment Share on other sites More sharing options...
martymoose Posted November 18, 2008 Author Share Posted November 18, 2008 after selecting my point and inserting my block, the layer temporarily changed to the line I was snapping to, but ultimately ended up on my current layer, just as before. This is more of what I am thinking... 1. insert my block as normal, snapping to my line as I always do (atleast this way I can preview my block on my cursor, as I am inserting it) 2. run lisp that takes the layer of the 'lastpoint' and makes this my current layer or 'clayer'. 3. run 'laymch' command converting my 'last' block to the current layer. 4. layerp If this will work, which I think it would, then I would need help with #2 above. I just dont know lisp, or I could do this myself. 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.