Jump to content

Recommended Posts

Posted

Hi,

 

I'm making a I beam routine.

 

now I would like to use a file with all the specification and make them use it in the routine. Such as this file. Specification.txt

 

(setq name (getstring T "\nGive name of I Beam : "))

(setq H 
     L 
     EA 
     ES 
     k 
     k1 
)

So I want to set those variable with the one in the .txt file according to the name given.

 

Anyone have a suggestion !

Posted

This looks more like a job for ASSOC:

(setq listProfiles '(("W530 x 85" 535 166 10.3 16.5 35 22)
                    ("W530 x 74" 529 166  9.7 13.6 32 21)))

(setq listBeam (cdr (assoc name listProfile))
(if listBeam
(setq H (nth 0 listBeam)
      L (nth 1 listBeam)
...

Posted

Well can I put it in another file.. since the I beam list is pretty long :D

Posted

This is enough .. :D

 

(mapcar 'set '(H L EA ES k k1) (list "W530 x 85" 535 166 10.3 16.5 35 22))

Posted

Well i'm pretty sure they work and all... But i'd like to make it a seperate file since I have like 288 different I beam :shock:

 

like it i would use :

 

(setq list (open file "r")

... etc

 

I know i'm asking alot :D

 

But I want to learn fast more and more

Posted

That's correct . and use the function read-line to read the line of values with while function to run to the end .

Posted

Now I get to this and it's not keeping the variable in memori..

 

(setq f (open "C:\\Users\\francois.levesque\\Documents\\specification.txt" "r"))

(setq name "W530 x 74")

(setq listt
(while (setq blist (read-line f))
    (if (wcmatch blist (strcat "*"name"*"))
      (princ blist)
    )
)
)

Now, what am I missing.

Posted

Well keep the line in memorie so i can use them and put each variable in a setq

Posted

You should step through each line of string and divide it by spaces or characters or what ever you have in your criteria .

 

functions may help in this regard .

vl-position
vl-string-search
vl-string-position

Posted

Ok Thanks ill see what I can make of this. now my day of work is over :D

Posted
Ok Thanks ill see what I can make of this. now my day of work is over :D

 

And for me it is time to go to bed :D

 

Good luck buddy .

Posted

Ok Well I figured out how to get the variable to stick now it doesnt reconize it as a list.. only a string

 

(setq f (open "C:\\Users\\francois.levesque\\Documents\\specification.txt" "r"))

(setq name "W530 x 74")

(while (setq blist (read-line f))
    (if (wcmatch blist (strcat "*"name"*"))
     (progn
   (setq a (substr blist 11))
    )
)

)

_$ A
"529 166 9.7 13.6 32 21"

So i need to put this into a list so i can use nth. So how can i put it into a list?

 

Unless some1 has a better idea

Posted
_$ A
"529 166 9.7 13.6 32 21"

So i need to put this into a list so i can use nth. So how can i put it into a list?

 

Unless some1 has a better idea

 

That means you did not read about the last three functions that I have posted for you to read :o

 

nth function does not help you in this regard :D

Posted

Well I did read them.. I'll give it more though :D

Posted
"529 166 9.7 13.6 32 21"

So i need to put this into a list so i can use nth. So how can i put it into a list?

 

(setq str "529 166 9.7 13.6 32 21")
(read (strcat "(" str ")"))

 

Alternatively, consider my String to List function for general purpose string parsing.

Posted
That means you did not read about the last three functions that I have posted for you to read :o

 

 

not sure how to use them everything is try give me errors :(

 

 (vl-string-search(vl-position 1 a))
; error: bad argument type: listp "529 166 9.7 13.6 32 21"
(setq b (vl-string-search 1 a))
; error: bad argument type: (or stringp symbolp): 1
(setq b (vl-string-position a 2))
; error: bad argument type: fixnump: "529 166 9.7 13.6 32 21"

Posted
not sure how to use them everything is try give me errors :(

 

Don't guess, read the documentation.

 

I provided the documentation for these functions in my response your previous thread:

 

http://www.cadtutor.net/forum/showthread.php?74012-Getting-a-specific-string-from-a-file-path&p=503361&viewfull=1#post503361

 

Looks like I wasted my time retrieving all the links to the information. Facepalm.gif

Posted (edited)
Don't guess, read the documentation.

 

I'm sorry Lee to dissapoint you. I did read the documentation on those.

Thing is i'm not yet able to understand autolisp way to work.

 

I'm still a beginner at this so even if I read no sure to understand the documentation. :(

Edited by CadFrank

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