Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
Posts: 187
Registered: ‎11-05-2008
Message 1 of 14 (299 Views)

Realy simple read question

299 Views, 13 Replies
03-21-2013 01:28 PM

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
*Expert Elite*
Kent1Cooper
Posts: 4,967
Registered: ‎09-13-2004
Message 2 of 14 (285 Views)

Re: Realy simple read question

03-21-2013 01:52 PM in reply to: richie.hodgson

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.

Kent Cooper
Distinguished Contributor
Posts: 187
Registered: ‎11-05-2008
Message 3 of 14 (267 Views)

Re: Realy simple read question

03-21-2013 02:18 PM in reply to: richie.hodgson

Hi I have attached the code for you to check out

Richie
Mentor
Posts: 1,682
Registered: ‎03-14-2004
Message 4 of 14 (248 Views)

Re: Realy simple read question

03-21-2013 07:45 PM in reply to: Kent1Cooper

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.

 

 

*Expert Elite*
Posts: 2,369
Registered: ‎11-24-2009
Message 5 of 14 (236 Views)

Re: Realy simple read question

03-21-2013 08:53 PM in reply to: richie.hodgson

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) )

 

Distinguished Contributor
Posts: 187
Registered: ‎11-05-2008
Message 6 of 14 (206 Views)

Re: Realy simple read question

03-24-2013 02:51 PM in reply to: richie.hodgson

That worked brilliantly, I am a happy camper now. Thanks all.

Richie
*Expert Elite*
Posts: 2,369
Registered: ‎11-24-2009
Message 7 of 14 (190 Views)

Re: Realy simple read question

03-24-2013 09:00 PM in reply to: richie.hodgson

richie.hodgson wrote:

That worked brilliantly, I am a happy camper now. Thanks all.


Glad i could help :smileyhappy:

 

Cheers 

 

 

Mentor
Posts: 825
Registered: ‎12-26-2005
Message 8 of 14 (168 Views)

Re: Realy simple read question

03-25-2013 06:13 AM in reply to: pbejse
Where does the QUOTE function fit in here? Is 'T1 needed, or : (vl-symbol-name (quote t1))
S
*Expert Elite*
Kent1Cooper
Posts: 4,967
Registered: ‎09-13-2004
Message 9 of 14 (153 Views)

Re: Realy simple read question

03-25-2013 01:22 PM in reply to: pbejse

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.]

Kent Cooper
Distinguished Contributor
Posts: 187
Registered: ‎11-05-2008
Message 10 of 14 (147 Views)

Re: Realy simple read question

03-25-2013 01:36 PM in reply to: richie.hodgson

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.

Richie

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community