+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 20
  1. #1
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2011
    Posts
    222

    Default Looking to use Wcmatch

    Registered forum members do not see this ad.

    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

    Code:
    (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 !

  2. #2
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    2,986

    Default

    This looks more like a job for ASSOC:
    Code:
    (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)
    ...
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  3. #3
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2011
    Posts
    222

    Default

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

  4. #4
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,616

    Default

    This is enough ..

    Code:
    (mapcar 'set '(H L EA ES k k1) (list "W530 x 85" 535 166 10.3 16.5 35 22))
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  5. #5
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2011
    Posts
    222

    Default

    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

    like it i would use :

    Code:
    (setq list (open file "r")
    
    ... etc
    I know i'm asking alot

    But I want to learn fast more and more

  6. #6
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,616

    Default

    That's correct . and use the function read-line to read the line of values with while function to run to the end .
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  7. #7
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2011
    Posts
    222

    Default

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

    Code:
    (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.

  8. #8
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,616

    Default

    What are you trying to achieve ?
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  9. #9
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2011
    Posts
    222

    Default

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

  10. #10
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,616

    Default

    Registered forum members do not see this ad.

    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 .
    Code:
    vl-position
    vl-string-search
    vl-string-position
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

Similar Threads

  1. wcmatch for html special characters
    By David Bethel in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 15th Jan 2012, 02:46 pm
  2. wcmatch
    By au-s in forum AutoLISP, Visual LISP & DCL
    Replies: 13
    Last Post: 29th Oct 2010, 04:47 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts