Jump to content

Coding Help - Adding numbers to text


Piper

Recommended Posts

I'm confused as to why it didn't work. What happened?

For what information you provided, I was able to make it work on my end.

 

I indulged you, now do me the same courtesy.

Link to comment
Share on other sites

  • Replies 37
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    12

  • SteveBubendorf

    7

  • Piper

    5

  • Lee Mac

    4

I'm sure it is something that I'm doing or setting incorrectly, (or didn't explain well enough in my first post). I used El. 115'-6" and EL. 114'-6 1/2". I added 10, which I thought was 10 feet, and got the following, repectively: EL. 126'-6" and EL. 125'-6".

 

I hate to be taking up your time, Alan, since this was just a learning excercise for me. I appreciate the help, though !!!!

Link to comment
Share on other sites

Nah, it's fun (when I have the time to play).

 

Post me a file with a few elevations. I will admit, it doesn't take into account the inches not being whole numbers (wasn't thinking about that).

I'm in the middle of a few things, but I might play around with it tonight.

Link to comment
Share on other sites

Alan,

 

I attached a drawing with a few elevation text entities. I also attached the previous Lisp file that I had to accomplish the task that we are communicating about. It seems to work for me as long as the text is formatted correctly and units are set properly, etc. I was just looking for another way to "skin the cat", I guess, as a learning experience.

 

Thanks, again, for the help !

Elevations.dwg

ELCI.lsp

Link to comment
Share on other sites

Steve,

 

Maybe a good place to learn about (distof) function:

 

(distof "115'-6")
1386.0

 

Maybe that would make the math a bit easier. -David

Link to comment
Share on other sites

Steve,

 

Maybe a good place to learn about (distof) function:

 

(distof "115'-6")
1386.0

 

Maybe that would make the math a bit easier. -David

Oh yeah, I wasn't thinking about units. I'm dumb.
Link to comment
Share on other sites

Dumb ! Yeah, right ! I wish I were only a fraction as "dumb" as you with this stuff, then ! Knowing that distof is the key, I'm still having trouble adjusting your code, perhaps cause I'm so "smart", then ???? Still workin' at it, though. Thanks, Alan ! Thanks, David!

Link to comment
Share on other sites

I've got to take a break from this, so if you guys do any more posting, I won't see it until later. (Been up for over 30 hours with insomnia. 'Gotta give sleep another shot.) I'll look at anything you post later, and respond accordingly. Thanks, again !!!

Link to comment
Share on other sites

Oh yeah, I wasn't thinking about units. I'm dumb.

 

 

Not quite! I forget ( distof ) 5 times fro every time I remember it.....

 

-David

Link to comment
Share on other sites

hi,

 

I am arriving in late, but this i will give you below should fix your problem. it is also usable for those who don't have vl function ( like me ) so it's look like more complicated than what have been proposed before but it's also more generic so you could adapt it by youself to make it run for your need. Basicaly it use the distof function to manage the architectural units. You can specify a string before and a string after to match for parsing your texts entities. For the example I ve been testing like this

>:add_value_in_text

>Type the layer name: ISOMOD

>Type a specific value for selecting text or key ENTER for all: 10'

>Type a text to match at begining of the value in the text: EL +

>Type a text to match at the end of the value in the text:

>Type the value to add: 845'

 

then all the EL +10' in my drawing has become EL +855'-0"

 

here is the source code freely licensed at just one restriction don't use ckado, capcpo or my real name for any commercial purpose. I just test it for your example it may have bug for other case.

 

the lsp file:

(defun addx2str ( x str str_match_begin str_match_end /

;; author: CAPCPO

;; 05.11.2010

stmp

i

ib ;begin

ie ;end

n

m

notfound

value

)

;;;; first find the value for addition and its position ;;;;;;;;;;;;;;;

;;;; if a str_match_begin specified ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(if

(eq str_match_begin "")

;;;;;;;;;;; if no str_match_begin ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq

i 1

ib i

)

;;;;;;;;;;; if str_match_begin ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(progn

(setq

i 1

n (strlen str)

notfound T

m (strlen str_match_begin)

)

(while

(and

(

notfound

)

(setq

stmp (substr str i m)

notfound (not (eq stmp str_match_begin))

i (1+ i)

)

)

(if

(null notfound)

(setq

i (+ i m)

ib (1- i)

)

)

)

)

 

(if

(null notfound)

(progn

(if

(eq str_match_end "")

;;;;;;;;;;;; if no str_match_end ;;;;;;;;;;;;;;;;

(setq

ie (1+ n)

)

;;;;;;;;;;;; if str_match_end ;;;;;;;;;;;;;;;;

(progn

(setq

notfound T

m (strlen str_match_end)

)

(while

(and

(

notfound

)

(setq

stmp (substr str i m)

notfound (not (eq stmp str_match_end))

i (1+ i)

)

)

(if

(null notfound)

(setq

ie (1- i)

)

)

)

)

;;;;;;;;;;;; if the str has been parsed then process the new string and send it back ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(if

(null notfound)

(setq

m (- ie ib)

stmp (substr str ib m) ; the sub text containig value for addition

value (distof stmp) ; convert architectural units to a real

str (if

(numberp value)

(strcat

(substr str 1 (1- ib))

(rtos (+ value x) 4 4) ;convert the new value to architectural

(substr str ie)

)

)

)

;;;;;;;;;;; if nothing were found then return nil ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

)

)

)

);fin

 

 

(defun c:add_value_in_text ( /

;; author: CAPCPO

;; 05.11.2010

n

i

ss

lent

assoc_str

str

x

s_value

s_match_begin

s_match_end

assoc_newlayer

s_x

)

(setq assoc_newlayer (cons 8 (getstring "\nType the layer name: ")))

(setq s_value (getstring 'cr "\nType a specific value for selecting text or key ENTER for all: "))

(setq s_match_begin (getstring 'cr "\nType a text to match at begining of the value in the text: "))

(setq s_match_end (getstring 'cr "\nType a text to match at the end of the value in the text: "))

(setq s_x (getstring 'cr "\nType the value to add: "))

(setq x (distof s_x))

(while

(not (numberp x))

(progn

(princ "\nerror: not able to read the value, try again")

(setq s_x (getstring 'cr "\nType the value to add: "))

(setq x (distof s_x))

)

)

 

(setq

ss (ssget "_X" (list (cons 0 "TEXT") (cons 1 (strcat s_match_begin s_value s_match_end "*"))))

i 0

)

 

(if

ss

(repeat (sslength ss)

(setq

lent (entget (ssname ss i))

assoc_str (assoc 1 lent)

assoc_layer (assoc 8 lent)

str (addx2str x (cdr assoc_str) s_match_begin s_match_end)

lent (if

str

(entmod (subst assoc_newlayer assoc_layer (subst (cons 1 str) assoc_str lent)))

(progn

(princ "\nError: impossible to get value in text")

(print (cdr assoc_str))

(print lent)

(prin1)

(exit) ;exit or just warning up to you

)

)

i (1+ i)

)

)

(progn

(princ (strcat "\nno text found with the value " s_match_begin s_value s_match_end "*"))

(prin1)

)

)

);fin

Link to comment
Share on other sites

I thanks you for the advices.

I will enclose the next lisp with code tag in the futur. As you read my thread you may have noticed that I have given CAPCPO as name of author and perhaps it makes you feel suspicious about my rights to publish this code. It just because i don't want to give my personnal name. Not because I don't want that people know who i am but because i don't want that my name be indexed by crawl bot. It just a question of privacy. I agree with you that this is problematic for copyrights. CAPCPO is the name of my website where I published some lisp. May be should I write capcpo.com instead of capcpo but that sounds too much like an advertissement...

One solution could be to insert a picture containing my name but i don't know if cadtutor will allow me to do that and if it is possible?

 

ckado

Link to comment
Share on other sites

I understand your concerns, but really, what's in a name?

 

1) Who's to say the name you display actually is your name anyway?

2) Out of 6 billion people, I wonder how many will have exactly the same name as you

3) What is anyone going to do with just a name anyway?

 

Just saying :)

Link to comment
Share on other sites

dear alanjt,

 

you 're right: what is a name? But have you ever try to launch search engines with your personal name? What would you think if all your private life is readable by 6 billion people?

 

ckado

Link to comment
Share on other sites

dear alanjt Lee Mac,

 

you 're right: what is a name? But have you ever try to launch search engines with your personal name? What would you think if all your private life is readable by 6 billion people?

 

Well, I suppose that depends on how much of your private life you upload to the net...

Link to comment
Share on other sites

In th early days of peer to peer moderated forums ( compuserve ) it was common practice and considered more professional to use your real name. I don't think that I've had any more or any less spam / phishing / pranks than most of the people that I know who use monikers. Hell, I even use my real name as a domain. There are still a few guys that hang out at the Autodesk forums that go back that far as well. So I wouldn't be but so worried about using the name given to you by your parents. My $0.02. -David

Link to comment
Share on other sites

a name and particulary my name is realy not a big deal but indexing names is already a problem, just think about it.

 

while few of us will upgrade themselves others will upload themselves

 

nice to talk with you

Link to comment
Share on other sites

  • 7 years later...

Hi All

 

Can you help me to get a lisp file for adding increment in the Chainage in the format of CH. 0+100.000 Km. Also please help if we can Place in the array

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...