Tomislav Posted June 12 Share Posted June 12 Hello everyone, I've made this function to add block with attributes to drawing, but it's not working, and when I call -insert, i get that the block references itself, but how when it's not even in block editor list? ;makes a block and inserts to drawing (defun cssabl_blk (pt station height /) (setvar "CMDECHO" 0) (if (not (tblsearch "BLOCK" "CSSABL")) ;_ _not (progn (entmake (list (cons 0 "BLOCK") (cons 2 "CSSABL") (cons 70 2) (cons 10 '(0. 0. 0.)) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "POINT") (cons 8 "0") (cons 10 '(0. 0. 0.)) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "ATTDEF") (cons 8 "0") (cons 10 '(0.0 0.0 0.0)) (cons 70 0) (cons 1 "") (cons 2 "STATION") (cons 40 2.0) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "ATTDEF") (cons 8 "0") (cons 10 '(0.0 0.0 0.0)) (cons 70 0) (cons 1 "") (cons 2 "HEIGHT") (cons 40 2.0) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "ENDBLK") (cons 8 "0") ) ;_ _list ) ;_ _entmake ) ;_ _progn ) ;_ _if (entmake (list (cons 0 "INSERT") (cons 2 "CSSABL") (cons 10 pt) (cons 66 1) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "ATTRIB") (cons 10 pt) (cons 1 station) (cons 2 "STATION") (cons 40 2.0) (cons 70 0) ) ;_ _list ) (entmake (list (cons 0 "ATTRIB") (cons 10 pt) (cons 1 height) (cons 2 "HEIGHT") (cons 40 2.0) (cons 70 0) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "SEQEND") ) ;_ _list ) ;_ _entmake );defun Quote Link to comment Share on other sites More sharing options...
lastknownuser Posted June 12 Share Posted June 12 You need to add dxf group code 3 when creating block, its for prompt i think. Here is edited code I just copied string of dxf code 2, works for me ;;; Copied to window at 2:06 PM 6/12/24 (defun cssabl_blk (pt station height /) (setvar "CMDECHO" 0) (if (not (tblsearch "BLOCK" "CSSABL")) ;_ _not (progn (entmake (list (cons 0 "BLOCK") (cons 2 "CSSABL") (cons 70 2) (cons 10 '(0. 0. 0.)) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "POINT") (cons 8 "0") (cons 10 '(0. 0. 0.)) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "ATTDEF") (cons 8 "0") (cons 10 '(0.0 0.0 0.0)) (cons 70 0) (cons 1 "") (cons 2 "STATION") (cons 3 "STATION") (cons 40 2.0) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "ATTDEF") (cons 8 "0") (cons 10 '(0.0 0.0 0.0)) (cons 70 0) (cons 1 "") (cons 2 "HEIGHT") (cons 3 "HEIGHT") (cons 40 2.0) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "ENDBLK") (cons 8 "0") ) ;_ _list ) ;_ _entmake ) ;_ _progn ) ;_ _if (entmake (list (cons 0 "INSERT") (cons 2 "CSSABL") (cons 10 pt) (cons 66 1) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "ATTRIB") (cons 10 pt) (cons 1 station) (cons 2 "STATION") (cons 40 2.0) (cons 70 0) ) ;_ _list ) (entmake (list (cons 0 "ATTRIB") (cons 10 pt) (cons 1 height) (cons 2 "HEIGHT") (cons 40 2.0) (cons 70 0) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "SEQEND") ) ;_ _list ) ;_ _entmake );defun ;;; End of text 1 Quote Link to comment Share on other sites More sharing options...
Steven P Posted June 12 Share Posted June 12 For the attributes try this format: (entmakex (list (cons 0 "ATTDEF") (cons 100 "AcDbEntity") (cons 8 "0") (cons 100 "AcDbText") (cons 10 '(0.0 0.0 0.0) ) (cons 40 2) (cons 1 "Default") (cons 100 "AcDbAttributeDefinition") (cons 3 "Prompt") (cons 2 "TAG") (cons 70 0) )) and also I think for attributes put in an attsync when the block is inserted 1 Quote Link to comment Share on other sites More sharing options...
Tomislav Posted June 12 Author Share Posted June 12 (edited) thank you, haven't found anywhere that this is obligatory, just wondering what it's for? also, maybe someone knows how to make theee atts invisible? Edited June 12 by Tomislav Quote Link to comment Share on other sites More sharing options...
lastknownuser Posted June 12 Share Posted June 12 (edited) 4 minutes ago, Tomislav said: thank you, haven't found anywhere that this is obligatory, just wondering what it's for? also, maybe someone knows how to make theee atts invisible? (cons 70 1) to be invisible Edited June 12 by lastknownuser 1 Quote Link to comment Share on other sites More sharing options...
Tomislav Posted June 12 Author Share Posted June 12 big thanx to you both Quote Link to comment Share on other sites More sharing options...
Steven P Posted June 12 Share Posted June 12 You probably all ready know this, but for others following this. If you use: (entget (car (entsel))) in the command line it will return the entity DXF code description for that (there are LISPs that do the same). Copy this and remove the '-1', '5' and '330' entries - this is the basis for entmake or entmakex (entmakex if you want to use the entity as in (setq MyNewEnt (entmakex (list ..... ))) ). If you entmake what you copy you will create a copy of the original entity. Anyway point being, if you are struggling with entmake, create a template entity as you want it, (entget.... ) it then you can modify the entmake code as required. Note that sometimes the order of the dxf codes is important too. I would ;; out parts so they can go back in again and check that it all still works OK. Sometimes what you make needs an attsync, redraw or regen to show the entity properly - blocks tend to like an attsync 2 Quote Link to comment Share on other sites More sharing options...
Tomislav Posted June 12 Author Share Posted June 12 (edited) Found this page today https://documentation.help/AutoCAD-DXF Great for finding DXF codes.. I also have a lisp that does list DXF codes from entities, but it lists only used ones, not all of them... I reluctantly use attsync cause often I must move some attributes independently of block, and that command resets their position... Also, wasn't aware that order is important, it's good to know, perhaps now I understand why some of my codes doesn't work Edited June 12 by Tomislav 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.