ThatGermanFool Posted June 4, 2019 Posted June 4, 2019 Hi guys, I'm wondering whether it is possible to use cutlclip and pasteclip for block Definition in Lisp. Normally, I would use an empty block, some attdefs, an endblk and entmake the objects I got with ssget in between. Afterwards, I'd delete the whole ssget selection set and insert the block instead. ;; create empty block (entmake (list (cons 0 "INSERT") (cons 2 blname) (cons 70 66) (cons 10 pIns) ) ) ;; end entmake [ENTMAKE OBJECTS HERE] (entmake (list (cons 0 "ATTDEF")[...])) ;; set end of block (entmake (list (cons 0 "ENDBLK"))) As entmaking inserts or polylines etc. is some work, I'd like to know if and how I could use pasteclip instead. Hope, my question is not that confusing. Cheers, Seb Quote
ThatGermanFool Posted June 5, 2019 Author Posted June 5, 2019 14 hours ago, ronjonp said: Perhaps try using THIS. Hi ronjonp, thank you for your answer, but the thread seems to be inaccessible to me "The topic or board you are looking for appears to be either missing or off limits to you." Quote
ronjonp Posted June 5, 2019 Posted June 5, 2019 (edited) 6 hours ago, ThatGermanFool said: Hi ronjonp, thank you for your answer, but the thread seems to be inaccessible to me "The topic or board you are looking for appears to be either missing or off limits to you." Attached is the code from TheSwamp. You should create an account there though ... lots of smart peeps there :). EntMaker CAB 05- MakeEntmake.lsp Edited June 5, 2019 by ronjonp 1 Quote
ThatGermanFool Posted June 5, 2019 Author Posted June 5, 2019 Thank you! It is not what I needed (I need to process nested blocks as well). But I'll consider signing up for the Swamp Quote
ronjonp Posted June 5, 2019 Posted June 5, 2019 (edited) Do you have to use entmake? Here is a simple example to add selected objects to a block using vla. (defun c:foo (/ a b s) (setq a (vla-get-activedocument (vlax-get-acad-object))) (setq b (vla-add (vla-get-blocks a) (vlax-3d-point '(0. 0. 0.)) "MyNewBlock")) ;; (vlax-for x b (vla-delete x)) (and (setq s (ssget)) (setq s (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))) (vlax-invoke a 'copyobjects s b nil) ) (princ) ) (vl-load-com) Edited June 5, 2019 by ronjonp 1 Quote
ThatGermanFool Posted June 5, 2019 Author Posted June 5, 2019 5 minutes ago, ronjonp said: Do you have to use entmake? Here is a simple example to add selected objects to a block using vla. (defun c:foo (/ a b s) (setq a (vla-get-activedocument (vlax-get-acad-object))) (setq b (vla-add (vla-get-blocks a) (vlax-3d-point '(0. 0. 0.)) "MyNewBlock")) ;; (vlax-for x b (vla-delete x)) (and (setq s (ssget)) (setq s (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))) (vlax-invoke a 'copyobjects s b nil) ) (princ) ) (vl-load-com) That looks like it could work. Thank you for pointing that out! I always forget that the visual Lisp functions are pretty powerful. Will try it later and report back to you Quote
ThatGermanFool Posted June 12, 2019 Author Posted June 12, 2019 This is what I needed. I came up with a combination of Copybase and Pasteblock and then modifying attributes with visual Lisp. Thanks for the hint tho. (vl-load-com) ;; prompt block name (setq blname (getstring "SAY MY NAME!\n")) ;; prompt remark (optional) (setq remark (getstring "Who is the one who knocks? (optional)\n")) ;; prompt objects to include (setq blockSelection (ssget)) ;; prompt insertion point (setq pIns (getpoint "What's the point?\n")) ;; copy to block (command "_.COPYBASE" pIns blockSelection "") (command "_.PASTEBLOCK" pIns) ;; change name (vla-put-name (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (cdr (assoc 2 (entget (entlast))))) blname) ;; add attributes (setq item (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blname)) ;; Name (vla-addattribute item 400 (+ acattributemodelockposition acAttributeModeInvisible) "name" (vlax-3D-point 0 0 0) "name" blname ) ;; Remark (vla-addattribute item 400 (+ acattributemodelockposition acAttributeModeInvisible) "remark" (vlax-3D-point 0 0 0) "remark" remark ) ;; update block with attribute (command "_.attsync" "_N" blname) ;; erase selection (command "_erase" blockSelection "") 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.