Search String Lisp

Search String Lisp

Anonymous
Not applicable
500 Views
3 Replies
Message 1 of 4

Search String Lisp

Anonymous
Not applicable

Hi guys!

 

Please help me with a small issue.

 

Is there any free .lsp that can search a specific string in a drawing and then use it in a formula? 🤔

Let me explain further. I have lots of dxf files, all of them having the following text string “TOTAL LENGTH:XXX” (XXX is variable). I need to enter every file and dimension some specific 2D objects with various lengths. I made the following lisp in which I set a dimension style as per my needs, but the dimension text height should be updated for every file at a time.

 

(defun c:dsq()(command "dimclrt" "7" "" )(command "dimasz" "1" "" )(command "dimtxt" "1" "" )(command "dimclrd" "1" "" )(command "dimclre" "1" "" )(command "dimscale" "1" "" )(command "dimdec" "0" "" )(command "dimtvp" "0.7" "" )(command "dimtih" "OFF" "" )(command "dimtoh" "OFF" "" )(command "dimexo" "0" "" )(command "dimexe" "0.8" "" )(command "dimcen" "2" "" )(command "dimtofl" "ON" "" )(command "dimtfill" "0" "" )(princ))

 

So i want that XXX to be included at dimasz/dimtxt and then set dimension text height => length value / 40 (this is an acceptable factor for any length).

 

Any hints will be highly apreciated!

0 Likes
501 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... (command "dimclrt" "7" "" )(command "dimasz" "1" "" )(command "dimtxt" "1" "" )(command "dimclrd" "1" "" )(command "dimclre" "1" "" )(command "dimscale" "1" "" )(command "dimdec" "0" "" )(command "dimtvp" "0.7" "" )(command "dimtih" "OFF" "" )(command "dimtoh" "OFF" "" )(command "dimexo" "0" "" )(command "dimexe" "0.8" "" )(command "dimcen" "2" "" )(command "dimtofl" "ON" "" )(command "dimtfill" "0" "" ) ....


I could probably come up with something for the DIMASZ/DIMTXT part, but not right now.  In the meantime, I suggest you set those dimensioning variables with (setvar) rather than (command), because it will shorten the code and will be faster [though with this number of settings, you may not notice the time difference].  The numerical values can be just numbers without quotation marks; a couple of them want a number 0 when done this way, rather than a text string "OFF" when done as a command.  You won't need the "" Enters at the ends.  And the System Variable names can be preceded by just an apostrophe, rather than enclosed in double-quotes before and after.  Try:

 

.... (setvar 'dimclrt 7) (setvar 'dimasz whatever) (setvar 'dimtxt whatever(setvar 'dimclrd 1) (setvar 'dimclre 1) (setvar 'dimscale 1) (setvar 'dimdec 0) (setvar 'dimtvp 0.7) (setvar 'dimtih 0) (setvar 'dimtoh 0) (setvar 'dimexo 0) (setvar 'dimexe 0.8) (setvar 'dimcen 2) (setvar 'dimtofl ON) (setvar 'dimtfill 0) ....

Kent Cooper, AIA
Message 3 of 4

Anonymous
Not applicable

Thanks for the reply @Kent1Cooper!

I’ll change the code as mentioned.

If you can take a look at the DIMASZ/DIMTXT part, i’ll be grateful 🤝

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:
.... (setvar 'dimtofl ON) ....

Missed one adjustment -- that should be  (setvar 'dimtofl 1) .

Kent Cooper, AIA
0 Likes