motee-z Posted August 1, 2015 Share Posted August 1, 2015 hello what is the best way to insert block with attribute already exist in search path with option to pick rotation i use this one but cant put bolck to layer (command "insert" "blkname.dwg" "non" n scx scy (- 300(/(*( GETangle p0 )200)PI)) ("attribu")) Quote Link to comment Share on other sites More sharing options...
Commandobill Posted August 1, 2015 Share Posted August 1, 2015 You could use vla to insert a block, but if you want to stick with that bit of code, you could always add this after that line to change the layer: (vla-put-layer (vlax-ename->vla-object (entlast)) "YOUR LAYER NAME HERE") Quote Link to comment Share on other sites More sharing options...
motee-z Posted August 1, 2015 Author Share Posted August 1, 2015 Thank you commandobill this okay but is there another way to insert block with attributes Quote Link to comment Share on other sites More sharing options...
Commandobill Posted August 1, 2015 Share Posted August 1, 2015 A really good example here. Quote Link to comment Share on other sites More sharing options...
Commandobill Posted August 1, 2015 Share Posted August 1, 2015 Lee-mac has some great ways of adding attributes here too. Quote Link to comment Share on other sites More sharing options...
motee-z Posted August 1, 2015 Author Share Posted August 1, 2015 commandobill this way not succeed i think because the last entity is attribute not the block i got a message{; error: Automation Error. Key not found} so this is my old lisp to get elevation of any point in a profile (defun c:ff () (setq angbs(getvar"angbase")) (setq aunts(getvar"aunits")) (setq insunt(getvar"insunits")) (if(null txth) (setq txth 1.25)) (setq txthnew(getreal(strcat"\n enter text height<sc:1/1000-txth=2.5;sc:1/500-txth=1.25;sc:1/200-txth=0.5>:" "<" (rtos txth 2 2)">:"))) (if txthnew(setq txth txthnew)) (if(null scrt) (setq scrt 1)) (setq scrtnew(getreal(strcat"\n enter scale ratio(vertical/horizental)" "<" (rtos scrt 2 2)">:"))) (if scrtnew(setq scrt scrtnew)) (if(null dh) (setq dh 0)) (setq dhnew (getreal(strcat"\n enter datum level:""<"(rtos dh 2 0)">:"))) (if dhnew(setq dh dhnew)) (initget 1) (setq p0 (getpoint "\pick any point on datum line")) (while (setvar"blipmode"0) (initget 1) (setq n (getpoint "\n pick point to get elevation")) ;;;;;;;;;;;;;;;;;;;;;;;; (setvar "angbase"(/ pi 2)) (setvar "aunits"2) (setvar"insunits"6) ;;;;;;;;;;;;;;;;;;;;;;; (command "insert" "lvm.dwg" "non" n txth txth (- 300(/(*( getangle n )200)PI)) (rtos (+ dh (/(-(cadr n)(cadr p0)) scrt)) 2 3)) ;(vla-put-layer (vlax-ename->vla-object (entlast)) "mark-level") (setvar"aunits"aunts) (setvar"angbase"angbs) (setvar"insunits"insunt) ) ) and attached the block lvm.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 2, 2015 Share Posted August 2, 2015 Maybe a simple do layer first expects layer to exist, this is where library functions creep in one for does layer exist, then maybe something like alanjt routine. (command "-layer" "S" "yourlayername" "" "insert" "blkname.dwg" "non" n scx scy (- 300(/(*( GETangle p0 )200)PI)) ("attribu")) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 2, 2015 Share Posted August 2, 2015 Hi , Try this [uNTESTED] program and let me know. NOTE: Add your desired layer name as indicated in Red in the program with the full path of the drawing . (defun c:ff (/ *error* vals dhnew n p scrtnew txthnew ang ent e lay) (defun *error* (x) (if vals (mapcar 'setvar '(angbase aunits insunits blipmode) vals) ) (and x (not (wcmatch (strcase x) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\n ** Error : " x " **")) ) ) (setq vals (mapcar 'getvar '(angbase aunits insunits blipmode))) (if (not txth) (setq txth 1.25) ) (if (not scrt) (setq scrt 1) ) (if (not dh) (setq dh 0) ) (if (and (setq filename (findfile[color="red"] "lvm.dwg"[/color])) ;; Add the full of the drawing (tblsearch "LAYER" (setq lay [color="red"]"0"[/color])) ;; Replace the "0" layer name with your desired layer name. (progn (initget 6) (cond ((setq txthnew (getreal (strcat "\n enter text height<sc:1/1000-txth=2.5;sc:1/500-txth=1.25;sc:1/200-txth=0.5>: <" (rtos txth 2 2) " >:" ) ) ) (setq txth txthnew) ) (t (setq txthnew txth)) ) ) (progn (initget 6) (cond ((setq scrtnew (getreal (strcat "\nEnter scale ratio [vertical/horizental] < " (rtos scrt 2 2) " >:" ) ) ) (setq scrt scrtnew) ) (t (setq scrtnew scrt)) ) ) (progn (initget 6) (cond ((setq dhnew (getreal (strcat "\n enter datum level < " (rtos dh 2 0) " > :" ) ) ) (setq dh dhnew) ) (t (setq dhnew dh)) ) ) (progn (initget 1) (setq p (getpoint "\pick any point on datum line")) ) ) (progn (mapcar 'setvar '(angbase aunits insunits blipmode) (list (/ pi 2) 2 6 0) ) (while (progn (initget 1) (setq n (getpoint "\nPick point to get elevation")) (setq ang (getangle n "\nSpecify Rotation angle :")) (setq ent (entlast)) ) (command "_.-insert" filename "non" n txth txth (- 300 (/ (* ang 200) pi)) (rtos (+ dh (/ (- (cadr n) (cadr p)) scrt)) 2 3) ) (if (not (eq ent (setq e (entlast)))) (entmod (append (entget e) (list (cons 8 lay)))) ) ) ) ) (*error* nil) (princ) ) Quote Link to comment Share on other sites More sharing options...
motee-z Posted August 2, 2015 Author Share Posted August 2, 2015 thank you tharwat great work i will modify all my old lisp to work in the same way Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 2, 2015 Share Posted August 2, 2015 thank you tharwat great work i will modify all my old lisp to work in the same way You're welcome , just ask if you in need of any clarification or any adds to the program 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.