Adjust attibute width

Adjust attibute width

Anonymous
Not applicable
1,049 Views
7 Replies
Message 1 of 8

Adjust attibute width

Anonymous
Not applicable

Hi everyone,

I have a little problem with some attibutes values when I insert a block.

I insert bloks automatically by reading a .CSV file. The problem comes when the width of the read is larger than the available space in my block. The get result is not as aesthetic as needed, I mean, it spreads trought de limits and when I put two contiguous bloks, the result is awfull.

I've read there's some routine that can fix that by ussing the ActiveX methods by clicking. I need get this done by ussing the entity commands or simpler

Best regards!

0 Likes
Accepted solutions (1)
1,050 Views
7 Replies
Replies (7)
Message 2 of 8

Moshe-A
Mentor
Mentor

@Anonymous hi,

 

Change the attribute justification to align?!

 

Moshe

 

 

0 Likes
Message 3 of 8

john.uhden
Mentor
Mentor

I hate doing this more than once.  My previous post didn't take.

I had the same situation where I consult.  So I built a Titleblock command to read the data from a .CSV, perform the insert and add the attributes, with their width factor adjusted.

Here are a couple of snippets from the code:

 (setq lengths
(list
'("DATE" 88)
'("DRAWN_BY" 80)
'("DIVE_STATUS" 328)
'("CORNER" 97)
'("PERIMETER" 98)
'("DEPTHS" 144)
'("SIZE" 147)
'("SHAPE" 101)
'("WALL/FLOOR" 313)
'("ORDER#" 102)
'("PO_NUMBER" 118)
'("CUSTOMER" 354) ;; increased (03-12-18)
'("COMPANY" 196)
)
)
;; where the integers represent the maximum attribute width to fit.
;; Later (where Att is the attribute's entity data)...
(and (setq Att (subst (cons 1 Value)(assoc 1 Att) Att)) (entmod Att) (setq D1 (apply 'distance (textbox Att))) (> D1 0) ;; added (04-18-18) (setq D2 (cadr (assoc Tag Lengths))) (setq Factor (min 1.0 (/ D2 D1))) (setq Att (subst (cons 41 Factor)(assoc 41 Att) Att)) (entmod Att) )

John F. Uhden

0 Likes
Message 4 of 8

Luís Augusto
Advocate
Advocate

Would that help you?

 

Dynamic Attribute Width

http://www.lee-mac.com/dynattwidth.html

0 Likes
Message 5 of 8

Anonymous
Not applicable

Hi,

This ain't exactly what I'm looking for. I have to auto-adjust the text width once the blok is put, without clicking them. I don't even know how long the inserted text will be...

Example:

What I have

1.png

What my LISP must do

2.png

 

Thank & Best Regards!

0 Likes
Message 6 of 8

john.uhden
Mentor
Mentor

I gave you my snippets of code.  The integers in the list of lengths represent the maximum width available within the titleblock (at a scale of 1) for each attribute.  Just measure each space and write it down to create your own list of attribute tags and lengths.  If the titleblock is inserted at a different scale, fear not, because the attributes will be scaled proportionately.  We are changing only their width factor.

Now if you don't know lisp at all, then you're stuck until you learn.  Our goal is to help you learn to help yourself, though sometimes we provide complete solutions to our regular friends.

John F. Uhden

Message 7 of 8

ВeekeeCZ
Consultant
Consultant

Perhaps something like THIS might help you to start.

 

Message 8 of 8

Anonymous
Not applicable
Accepted solution

Hi everyone!

I was looking for the eassiest method to achieve my goal, so I refused to use vlax- methods, because I've read it doesn't work in Mac computers so I had to found another way and so I did.

I've achieved my goal by ussing entities and subentities so it's compatible with MAC. I let here the code:

(setq ename (entlast))
(setq dist2 (getpropertyvalue ename "AcDbDynBlockPropertyDistance2"));returns the specified block's y_length (previously defined at block editor)
  (setq der (entget ename))
  (setq der (entget (entnext (cdr (assoc -1 der)))))
  (while (/= (cdr (assoc 0 der)) "SEQEND")
    (setq T1 (abs (-(cadr (assoc 10 der)) (cadr (assoc 11 der))))
	  E (- (/ dist2 (abs (* 2 T1))) 0.1))
    (if (< E 1)
      (setq der (subst (cons 41 E)(assoc 41 der) der))
    )
    (entmod der)
    (setq der (entget (entnext (cdr (assoc -1 der)))))
  )

Best Regards

0 Likes