Tomislav Posted March 24 Posted March 24 (edited) hello everyone, i need help with positioning attdefs, the problem is what ever i change they end up at ucs origin instead of at supplied pt. here is part of lisp that creates block if it doesn't exist and part that inserts it (entmake (list (cons 0 "BLOCK") (cons 2 "9102_DETALJNA_TOCKA") (cons 70 2) (cons 10 '(0.0 0.0 0.0)) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "POINT") (cons 8 "0") (cons 10 pt) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "CIRCLE") (cons 8 "0") (cons 10 pt) (cons 40 (/ t_ht 5)) ) ;_ _list ) (entmakex (list (cons 0 "ATTDEF") (cons 100 "AcDbEntity") (cons 8 "DT_broj_tocke") (cons 100 "AcDbText") (cons 10 '(0.0 0.0 0.0)) ;pozicija (cons 40 t_ht) (cons 1 "") (cons 100 "AcDbAttributeDefinition") (cons 3 "") (cons 2 "BROJ_TOCKE") (cons 70 0) ; invisible (0-visible) (cons 72 0) ; horizontal justification (cons 74 2) ; vertical justification ) ;_ _list ) ;_ _entmakex (entmakex (list (cons 0 "ATTDEF") (cons 100 "AcDbEntity") (cons 8 "DT_visina_terena") (cons 100 "AcDbText") (cons 10 '(0.0 0.0 0.0)) (cons 40 t_ht) (cons 1 "") (cons 100 "AcDbAttributeDefinition") (cons 3 "") (cons 2 "HTERENA") (cons 70 0) (cons 72 0) (cons 74 2) ) ;_ _list ) ;_ _entmakex (entmake (list (cons 0 "ENDBLK") (cons 8 "0") ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "INSERT") (cons 2 "9102_DETALJNA_TOCKA") (cons 10 pt) (cons 66 1) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "ATTRIB") (cons 10 pt) (cons 1 pt_num) (cons 2 "BROJ_TOCKE") (cons 40 t_ht) (cons 70 0) ; invisible (0-visible) (cons 72 0) ; horizontal justification (cons 74 2) ; vertical justification ) ;_ _list ) ;_ entmake (entmake (list (cons 0 "ATTRIB") (cons 10 pt) (cons 1 teren) (cons 2 "HTERENA") (cons 40 t_ht) (cons 70 0) (cons 72 0) (cons 74 2) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "SEQEND") ) ;_ _list ) ;_ _entmake (command "regenall") only when i explode made block, attributes move from ucs to point position Edited March 24 by Tomislav Quote
Saxlle Posted March 24 Posted March 24 (edited) Hey @Tomislav, Maybe the best way is to calculate the "point position" according to "supplied pt" (I supposed it's from somewhere where the user pick a point to insert a block?). If it's so, then use this: (setq pt_attdef_one (polar pt 0.785 10) ;; 0.785 is the angle of 45 degree, 10 is the length (you can change the angle and length) pt_attdef_second (polar pt 5.497 10) ;; 5.497 is the angle of 315 degree, 10 is the length (you can change the angle and length) ) Then, you can change it in your code to look like this: (entmake (list (cons 0 "BLOCK") (cons 2 "9102_DETALJNA_TOCKA") (cons 70 2) ;; (cons 10 '(0.0 0.0 0.0)) ;; insted of '(0.0 0.0 0.0), that need to be "supplied point" from user stored in variable "pt"!? (cons 10 pt) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "POINT") (cons 8 "0") (cons 10 pt) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "CIRCLE") (cons 8 "0") (cons 10 pt) (cons 40 (/ t_ht 5)) ) ;_ _list ) (entmakex (list (cons 0 "ATTDEF") (cons 100 "AcDbEntity") (cons 8 "DT_broj_tocke") (cons 100 "AcDbText") ;; (cons 10 '(0.0 0.0 0.0)) ;pozicija --> insted of '(0.0 0.0 0.0) you need to put "pt_attdef_one", that is the new calculated position from "pt" (cons 10 pt_attdef_one) (cons 40 t_ht) (cons 1 "") (cons 100 "AcDbAttributeDefinition") (cons 3 "") (cons 2 "BROJ_TOCKE") (cons 70 0) ; invisible (0-visible) (cons 72 0) ; horizontal justification (cons 74 0) ; vertical justification ) ;_ _list ) ;_ _entmakex (entmakex (list (cons 0 "ATTDEF") (cons 100 "AcDbEntity") (cons 8 "DT_visina_terena") (cons 100 "AcDbText") ;; (cons 10 '(0.0 0.0 0.0)) --> insted of '(0.0 0.0 0.0) you need to put "pt_attdef_second", that is the new calculated position from "pt" (cons 10 pt_attdef_second) (cons 40 t_ht) (cons 1 "") (cons 100 "AcDbAttributeDefinition") (cons 3 "") (cons 2 "HTERENA") (cons 70 0) (cons 72 0) (cons 74 0) ) ;_ _list ) ;_ _entmakex (entmake (list (cons 0 "ENDBLK") (cons 8 "0") ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "INSERT") (cons 2 "9102_DETALJNA_TOCKA") (cons 10 pt) (cons 66 1) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "ATTRIB") ;; (cons 10 pt) --> insted of "pt" you need to put "pt_attdef_one" (cons 10 pt_attdef_one) (cons 1 pt_num) (cons 2 "BROJ_TOCKE") (cons 40 t_ht) (cons 70 0) ; invisible (0-visible) (cons 72 0) ; horizontal justification (cons 74 0) ; vertical justification ) ;_ _list ) ;_ entmake (entmake (list (cons 0 "ATTRIB") ;; (cons 10 pt) --> insted of "pt" you need to put "pt_attdef_second" (cons 10 pt_attdef_second) (cons 1 teren) (cons 2 "HTERENA") (cons 40 t_ht) (cons 70 0) (cons 72 0) (cons 74 0) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "SEQEND") ) ;_ _list ) ;_ _entmake (command "regenall") And you will get something like this from picture (I put a number "1" and "BR" just for the example): P.S. Mislim da ti je tako lakse da namestis ubacivanje/definisanje pozicije gde ce koji atribut biti ubacen u odnosu na izabranu tacku koju korisnik izabere, pa tako da izracunas nove pozicije tacaka za ubacivanja atributa1 i atributa2 svaki put kada se ubacuje blok. Probaj, nadam se da ce ti pomoci. I da, svuda gde imas (cons 74 2) promeni u (cons 74 0). Edited March 24 by Saxlle Quote
Tomislav Posted March 24 Author Posted March 24 (edited) the attributes should be right there next to point without calculating, that's why this (cons 10 ) is for...when defying attributes here is relative position to insertation point in my other lisp this function works normally, but in this one it doesn't... her is that function (defun tv:cssabl_blk (pt station height /); 3D point,string,string (setvar "CMDECHO" 0) (tv:create-layer "cssa" 7 0) (setvar 'CLAYER "cssa") (if (not (tblsearch "BLOCK" "CSSABL")) ;_ _not (progn (entmake (list (cons 0 "BLOCK") (cons 2 "CSSABL") (cons 70 2) (cons 10 '(0.0 0.0 0.0)) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "POINT") (cons 8 "0") (cons 10 '(0.0 0.0 0.0)) ) ;_ _list ) ;_ _entmake (entmakex (list (cons 0 "ATTDEF") (cons 100 "AcDbEntity") (cons 8 "cssa") (cons 100 "AcDbText") (cons 10 '(0.0 0.0 0.0)) ;;pozicija (cons 40 0.3) (cons 1 "Default") (cons 100 "AcDbAttributeDefinition") (cons 3 "Station:") (cons 2 "STATION") (cons 70 1) ; invisible (0-visible) (cons 72 0) ; horizontal justification (cons 74 1) ; vertical justification ) ;_ _list ) ;_ _entmakex (entmakex (list (cons 0 "ATTDEF") (cons 100 "AcDbEntity") (cons 8 "cssa") (cons 100 "AcDbText") (cons 10 '(0.0 0.0 0.0)) (cons 40 0.3) (cons 1 "Default") (cons 100 "AcDbAttributeDefinition") (cons 3 "Height:") (cons 2 "HEIGHT") (cons 70 1) (cons 72 0) (cons 74 3) ) ;_ _list ) ;_ _entmakex (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 0.3) (cons 70 1) ; invisible (0-visible) (cons 72 0) ; horizontal justification (cons 74 1) ; vertical justification ) ;_ _list ) ;_ entmake (entmake (list (cons 0 "ATTRIB") (cons 10 pt) (cons 1 height) (cons 2 "HEIGHT") (cons 40 0.3) (cons 70 1) (cons 72 0) (cons 74 3) ) ;_ _list ) ;_ _entmake (entmake (list (cons 0 "SEQEND") ) ;_ _list ) ;_ _entmake (command "regenall") (princ) );defun Edited March 24 by Tomislav Quote
Saxlle Posted March 24 Posted March 24 If values for 72 and 74 dxf codes supplied, you will get this (link): If group 72 and/or 74 values are nonzero, then the text insertion point values are ignored and new values are calculated by AutoCAD based on the text alignment point and the length of the text string itself (after applying the text style). If you want to avoid this, than you can for the second attribut making according to insertation point (pt) do this "(cons 10 (cons 10 (list (car pt) (- (cadr pt) 0.3) (caddr pt)))" (where 0.3 is the text height), and you will get something like this and need to put (cons 74 0) in all attribut definition: If (cons 74 0) are non-zero value, I get this: Also, you can change (cons 70 0) to be visible, otherwise the values are not appears to be visible in drawing. 1 Quote
Tomislav Posted March 24 Author Posted March 24 yes, that solves it, thank you! didn't read that anywhere about omitting 72 and 74 ... now i'm really puzzled why my other lisp (second one submitted) works and first doesn't and they both have same 72 and 74 non zero values??? Quote
Saxlle Posted March 24 Posted March 24 (edited) You're welcome . This part of code can be just an option/alternative to get a attribute position (it's not neccessery). (setq pt_attdef_one (polar pt 0.785 10) ;; 0.785 is the angle of 45 degree, 10 is the length (you can change the angle and length) pt_attdef_second (polar pt 5.497 10) ;; 5.497 is the angle of 315 degree, 10 is the length (you can change the angle and length) ) On 3/24/2025 at 2:28 PM, Tomislav said: didn't read that anywhere about omitting 72 and 74 Expand I think if both values nonzero 72 2 and 74 3, or 72 for e.g 1 and 74 0, or 72 for e.g 0 and 74 1, the text insertion point values are ignored. On 3/24/2025 at 2:28 PM, Tomislav said: now i'm really puzzled why my other lisp (second one submitted) works and first doesn't and they both have same 72 and 74 non zero values??? Expand Really don't know... P.S. Bitno je da radi sada Edited March 24 by Saxlle 1 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.