I have a file of coordinates code, x, y, z. which I have read and separated by CAR, CADR, CADDR, CADDDR into seperate elements, I can output the x, y, and z to text using RTOS but I am having trouble outputting the code to text,
(setq t1 (car PTa)) reads the code just fine
(command "._text" (Mapcar '+ pt3 pt1 pt19) "90" (strcat t1) ) doesn't work, I am in a hurry and don't have time to find out how to fix it.
@richie_hodgson wrote:....
(setq t1 (car PTa)) reads the code just fine
(command "._text" (Mapcar '+ pt3 pt1 pt19) "90" (strcat t1) ) doesn't work....
Is the current Text Style of fixed height? If not, you need to add a response to the height prompt.
If that's not the problem, what is PTa?
If it's a typical three-numerical-coordinates point list [I jump to that conclusion because of the variable name], replace (strcat t1) with (rtos t1).
If it's a list of elements broken out of a line read from a file like your sample, then to work as I think you want, the list would need to be four separate text strings, or maybe a text string followed by a point list, not [for example] the whole line as one text string, the way (read-line) would return it. But if PTa is in that kind of form, it should work [subject to my first question above], but the (strcat) wrapper applied to t1 wouldn't be needed [though it shouldn't hurt].
If it's something else, write back.
Hi I have attached the code for you to check out
Hi kent , please see the same ptopic since 19-03-2013.
http://forums.autodesk.com/t5/user/viewprofilepage/user-id/526522
I upload some sugestions.
@richie_hodgson wrote:I have a file of coordinates code, x, y, z. which I have read and separated by CAR, CADR, CADDR, CADDDR into seperate elements, I can output the x, y, and z to text using RTOS but I am having trouble outputting the code to text,
(setq t1 (car PTa)) reads the code just fine
(command "._text" (Mapcar '+ pt3 pt1 pt19) "90" (strcat t1) ) doesn't work, I am in a hurry and don't have time to find out how to fix it.
(if (numberp t1) (itoa t1) (vl-symbol-name t1) )
@richie_hodgson wrote:That worked brilliantly, I am a happy camper now. Thanks all.
Glad i could help
Cheers
@pbejse wrote:....(if (numberp t1) (itoa t1) (vl-symbol-name t1) )
Maybe I'm misunderstanding something, but I wondered what I think is the same thing as stevor. Presumably the t1 variable contains a text string if it's not a number, and a string is what the (itoa) 'then' argument returns, so to be equivalent, that's what the 'else' argument should return, too. Setting it to a string:
Command: (setq t1 "George")
"George"
Then:
Command: (vl-symbol-name t1)
; error: bad argument type: symbolp "George"
What I think stevor is asking about [either of two ways]:
Command: (vl-symbol-name 't1)
"T1"
Command: (vl-symbol-name (quote t1))
"T1"
Those return the name of the variable [capitalized, whether or not you want that], not the string it contains. Should it be:
(if (numberp t1) (itoa t1) t1)
instead?
Also, if it's a number, might it just as easily be a real number rather than an integer? If it's a coordinate extracted from a point list, it will be. That suggests using (rtos) with appropriate arguments, rather than (itoa).
But maybe I don't understand well enough what's wanted. It doesn't help that the OP's "that worked brilliantly" message doesn't claim to be a Reply to pbejse's message, though I can't picture its being a Reply to any of the others. [About that: I have found that if you are not signed in, and you pick on Reply and then sign in because it requires you to, your resulting message comes across as if in Reply to the original post, not in Reply to the message on whose Reply button you picked. I would have to assume that's what happened.]
Hi everyone, the code was supposed to read a file with <name, x, y, z> as per attached. Name could be a string or a number i.e. point code or spike number, I found that(command "._text" (Mapcar '+ pt3 pt1 pt19) "90" (if (numberp t1) (itoa t1) (vl-symbol-name t1))) in the code worked wonderfully to convert either of those options. I have attached both the final code and an example file for your perusal, since the code works there need not be more in this discussion unless there is an alternative that I could explore.
Kent,
the error that OP was getting, was being caused by (strcat t1), and t1 was obtained by reading a txt file that had two types of text lines
(setq L "2500 417000.27 790894.93 0");; string type "b", starts with a number
(setq PTa (read (strcat "(" L ")")));;subroutine used in the code to transform each strig in a list
(setq t1 (car PTa));;if type "a" returns a SYM, if type "b" returns an integer
(if (numberp t1);;evaluates to a real or an integer
(itoa t1);;turns it in a string
(vl-symbol-name t1);;otherwise gets the SYM name as a string )
this was the way that pbejse found to provide a string to the text command.
Henrique
@hmsilva wrote:Kent,
(setq PTa (read (strcat "(" L ")")));;subroutine used in the code to transform each strig in a list
(setq t1 (car PTa));;if type "a" returns a SYM, if type "b" returns an integer
(if (numberp t1);;evaluates to a real or an integer
(itoa t1);;turns it in a string
(vl-symbol-name t1);;otherwise gets the SYM name as a string )
this was the way that pbejse found to provide a string to the text command.
Henrique
Thats right Henrique. thank you for that.
Exactly,
(vl-symbol-name t1) evaluates the variable t1 hence not quoted
(read L) <--- This is why , the OPs existing routine converts the string value to a symbol
(setq PTa (LN2Pt LN))
(setq t1 (car PTa)) <-- a symbol as a result of the function LN2Pt. If i had my way i would have converted the string to its intended format from the get-go inside LN2Pt.But thats what the OP already had and he understands the way it works so no need to confuse the OP by introducing another function. thus i opted to convert whats already there.
Cheers
@Kent1Cooper wrote:
.....(if (numberp t1) (itoa t1) t1)
instead?
Also, if it's a number, might it just as easily be a real number rather than an integer? If it's a coordinate extracted from a point list, it will be. That suggests using (rtos) with appropriate arguments, rather than (itoa).
The sample text file posted by the OP clearly shows that its not. besides the line in question is the part where the first characters of a sequence of the comma delimited file
(Mapcar '+ pt3 pt1 pt19) <-- the part where the value is written on the table and clearly not the corrdinates thus itoa for number.
@Kent1Cooper wrote:Those return the name of the variable [capitalized, whether or not you want that], not the string it contains.
As i mentioned on my previous post the read function utilize by the LN2Pt already had that on Uppercase. No harm on my part using vl-symbol-name.
My point being, LN2Pt dictated my reasoning for the use vl-symbol-name.
BTW: ti value is not a string, but a symbol [LN2Pt]
Cheers
pbejse wrote:
...
Thats right Henrique. thank you for that.
...
You're welcome, pbejse
just one more thing, in my previous post
had a typo, I forgot to post the text line type "a" ...
(setq L "b5 415560.92 790268.40 0");; string type "a", starts with a letter
Cheers
Henrique