dimension convet to text lisp

dimension convet to text lisp

Gaganpatel
Collaborator Collaborator
2,537 Views
13 Replies
Message 1 of 14

dimension convet to text lisp

Gaganpatel
Collaborator
Collaborator

Hi every one,

 

Please share dimension convert to text lisp file.

0 Likes
2,538 Views
13 Replies
Replies (13)
Message 2 of 14

ВeekeeCZ
Consultant
Consultant
You know that DIMENSION is a collection of lines, blocks and MTEXT. So how that can be "converted". What to do with the rest of entities?

The EXPLODE command does not work for you?

Or do you need just a string for your lisp program?
0 Likes
Message 3 of 14

Gaganpatel
Collaborator
Collaborator

In place of mtext i need exploded text and  other entities will be the same.

for example if object dimension is 500MM after reducing the object dimension will no be change.it will remain same.

 

 

 

0 Likes
Message 4 of 14

Kent1Cooper
Consultant
Consultant

One way:

 

(if (setq dimsel (entsel "\nSelect Dimension to override text with measured distance: "))

  (progn

    (setq

      dim (car dimsel)

      ddata (entget dim)

    )

    (entmod (subst (cons 1 (rtos (cdr (assoc 42 ddata)))) (assoc 1 ddata) ddata))

  )

)

 

That uses current Units mode and precision settings, which may not be the same as those settings in the Dimension Style, so you may need to specify differently.

 

EDIT:  By the way, that's just for the text equivalent of the measured-distance value.  If you might have some already-supplied override text content as pre- or suffix to that, the code can be modified to include that.

Kent Cooper, AIA
0 Likes
Message 5 of 14

ВeekeeCZ
Consultant
Consultant

This applies the current text value as a text override.

 

(defun c:DimValueToOverride ( / ss i ent bent ed txt pos)

  (if (setq ss (ssget "_:L" '((0 . "DIMENSION"))))
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i)))
            bent (tblobjname "BLOCK" (cdr (assoc 2 (entget ent)))))
      (while (setq bent (entnext bent))
        (if (= (cdr (assoc 0 (setq ed (entget bent)))) "MTEXT")
          (progn
            (setq txt (cdr (assoc 1 bdef)))
            (if (setq pos (vl-string-search ";" txt))
              (setq txt (substr txt (+ 2 pos)))))))
      (entmod (subst (cons 1 txt)
                     (assoc 1 (entget ent))
                     (entget ent)))))
  (princ)
)
0 Likes
Message 6 of 14

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

....  If you might have some already-supplied override text content as pre- or suffix to that, the code can be modified to include that.


Such as this:

(defun C:DMTO ; = Dimension Measurement-Text Override
  (/ dimsel dim ddata)
  (if (setq dimsel (entsel "\nSelect Dimension to override text with measured distance: "))
    (progn
      (setq
        dim (car dimsel)
        ddata (entget dim)
      ); setq
      (entmod
        (subst
          (cons 1
            (cond
              ((member '(1 . "") ddata); text is only default [no override already]
                (rtos (cdr (assoc 42 ddata))); text equivalent of measured distance
              ); default condition
              ((wcmatch (cdr (assoc 1 ddata)) "*<>*"); override including measured distance
                (vl-string-subst (rtos (cdr (assoc 42 ddata))) "<>" (cdr (assoc 1 ddata)))
; replace measured-distance portion with equivalent text override ); measured-distance-included condition ((strcat (rtos (cdr (assoc 42 ddata))) " " (cdr (assoc 1 ddata)))) ; none-of-the-above; add measured-distance text to beginning of override ); cond ); cons (assoc 1 ddata) ddata ); subst ); entmod ); progn ); if (princ) ); defun

Note the third option, if there's an override that doesn't  include the measured distance -- as written, it adds the measured distance [and a space] before the current override text, but you may want a different outcome if you might have that situation.

 

 

Other questions arise:

 

It seems like a potentially dangerous thing to do, with concerns such as potential liability implications.  So I'd be very careful about using it only in very limited and thoughtfully-evaluated circumstances.  You might even have it always include something like "N.T.S." [= Not To Scale] at the end.

 

This is only for distance  Dimensions.  What if you pick an angular  Dimension?  Would there ever be a need for that?  I can't imagine one, but that could be accommodated if necessary, or it could be built to prevent  use on angular Dimensions.

Kent Cooper, AIA
0 Likes
Message 7 of 14

hak_vz
Advisor
Advisor

 Not so sophisticated as the above solutions, but it does the trick.

 

 

 

(defun C:ed_dim ( / prec text_height e ent pt1 pt2 di)
(setq prec (getint "\nNumber precision for dimension text >" ))
    (while
        (setq 
            e (car (entsel "\nSelect dimension object: >"))
            ent (entget e)
            pt1 (getpoint "\nSelect dimension start : >")
            pt2 (getpoint "\nSelect dimension end : >")
            di (rtos (distance pt1 pt2) 2 prec)
            ent (subst (cons 1 di) (assoc 1 ent) ent)
            ent (entmod ent)
         )
     )
(princ)
)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 8 of 14

Gaganpatel
Collaborator
Collaborator

Thanks for shearing the lisp file but it is solve my purpose.

 

But better understanding again i am sending example file.

 

 

 

Regards.

 

Kalandi Paital

0 Likes
Message 9 of 14

Gaganpatel
Collaborator
Collaborator

Thanks for shearing the lisp file but it is not solve my purpose.

 

But better understanding again i am sending example file.

 

 

 

 

Regards.

 

Kalandi Paital

0 Likes
Message 10 of 14

Kent1Cooper
Consultant
Consultant

@Gaganpatel wrote:

.... i am sending example file.

 

....

Since that is all reduced to separate Mtext and Line objects, I repeat @ВeekeeCZ's earlier question:  Does EXPLODE not do what you want?  In your earlier Example file.dwg, the result was still a Dimension object.  What are you really trying to do?

Kent Cooper, AIA
0 Likes
Message 11 of 14

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

Actually we are making assembly and from that assembly we are making part drawing and that drawing we have to fit in A4 size sheet.

Some times the object length around 10Mtr in that case we have stretch my object to the required length and convert that dimension into exploded text.

 

 

0 Likes
Message 12 of 14

Kent1Cooper
Consultant
Consultant

How about just Plotting at a different scale, so that it fits on your sheet size without destroying the Dimensions?

 

Or, if you can't just EXPLODE and then STRETCH because the text doesn't reposition itself, can you not use the earlier routines on this thread, STRETCH as required, and then EXPLODE?

 

In your second drawing, you have a lot of shorter distances that make up the overall length.  I'm trying to picture how you can STRETCH the overall length shorter without seriously distorting the relationship between, and maybe overlapping, some of the shorter intermediate lengths....  Before and after in the same drawing would help us understand what you're doing.

Kent Cooper, AIA
0 Likes
Message 13 of 14

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

 

Please see the sample drawing.

Message 14 of 14

Kent1Cooper
Consultant
Consultant

So it seems you're STRETCHing every section [except the shortest ones] separately, and apparently eye-balling them because the shortened distances are not proportional to the starting distances.  Does it not work to apply one of the routines from earlier in this thread to make the text overrides [but leave them as Dimensions so that the text will re-position itself when they are STRETCHed], then do the STRETCHing, and then EXPLODE the Dimensions?  If that doesn't work, explain further the steps you want to take to get from the full-length layout to the Shop Drawing layout.

Kent Cooper, AIA
0 Likes