+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
  1. #1
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Dec 2009
    Posts
    152

    Love write a list into text file and return back as list

    Registered forum members do not see this ad.

    Dear all,

    I am developing one project for my cencern, in this project i have so many details in a list format. I want to write all the lists in a text file as a organized manner and get it back as a list whenever required.

    Please try forme.

    my mail.
    mkumar@mabanisteel.com

  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
    4,008

    Default

    Use PRINT statement with the list as argument to record it in the data file.

    After call READ-LINE to retrieve it from file, respectively READ to evaluate the string into a list.

  3. #3
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Dec 2009
    Posts
    152

    Default

    Dear msasu,
    Thank you so much. I wasted full day for this task.
    I didn't use both the function till now which make me mad.
    Anyhow thank you so much for your immediate response.

    Can you explain in detail about that functions.

  4. #4
    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
    4,008

    Default

    You are welcomed!


    The below examples may help you:

    To record a list into a text file:
    Code:
    (setq TargetFile (open "c:\\test_20091210.txt" "w"))   ;open file to write
    (princ '(1 2 3 4) TargetFile)                          ;record the list into file
    (close TargetFile)                                     ;close the file
    To retrieve that list from the file:
    Code:
    (setq SourceFile (open "c:\\test_20091210.txt" "r"))   ;open file to read
    (setq FileLine (read-line SourceFile))                 ;read file content (one line in this case)
    (close SourceFile)                                     ;close the file
    (setq theListFromFile (read FileLine))                 ;evaluate the string into a list
    For more and better explanations may use AutoLISP’s help.

    Regards,

  5. #5
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Dec 2009
    Posts
    152

    Default

    can you give me your mail ID to contact you if i face any problem in my task.
    my mail Id
    mkumar@mabanisteel.com

  6. #6
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    This should help you for writing to files:
    http://www.cadtutor.net/forum/showth...ILE#post271366
    DropBox
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  7. #7
    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
    4,008

    Default

    Quote Originally Posted by muthu123 View Post
    can you give me your mail ID to contact you if i face any problem in my task.
    my mail Id
    You will get better support if continue to post on forum – there are many great programmers that can help you and a lot of good approaches for each issue to choose from.

    Also, is a good practice to avoid posting in clear your e-mail address since this sound like an invitation to spammers. For the case when you cannot avoid doing so, just spell it like:
    user at domain dot extension
    at list this will avoid automatically parsing.

  8. #8
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Dec 2009
    Posts
    152

    Default

    Quote Originally Posted by alanjt View Post
    This should help you for writing to files:
    http://www.cadtutor.net/forum/showth...ILE#post271366

    Thank you so much Mr.alanjt.

    Sincerely,
    Muthu Kumar

  9. #9
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    Quote Originally Posted by muthu123 View Post
    Thank you so much Mr.alanjt.

    Sincerely,
    Muthu Kumar
    Happy to help.
    DropBox
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  10. #10
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Dec 2009
    Posts
    152

    Default

    Registered forum members do not see this ad.

    Dear friends,
    can you help me to modify this following lisp

    (defun save_input_as_a_text_file_from_list ()
    (setq input_text_file (strcat path_input_endwall "/endwall.txt"))
    (setq file_descr (open input_text_file "w"))
    (close file_descr)

    (setq list_type_variables (list "main_input_building_details" "clear_span_dialog_details" "left_end_column_size" ))

    (setq file_descr (open input_text_file "a"))
    (setq i 0)
    (repeat (length list_type_variables)
    (write-line (nth i list_type_variables) file_descr)
    (princ (eval (read (nth i list_type_variables))) file_descr)
    (princ "\n" file_descr)
    (setq i (1+ i))
    )
    (close file_descr)
    )

    I need a text file like this
    firstline will be varible name
    nextline will be the whole list

    main_input_building_details
    (("frame_type" "typical_endwall" "endwall_type_left" "endwall_girt_type_left" "corner_column_left_endwall" "endwall_column_spacings_left" "bay_spacings_sidewall" "building_length" "building_width" "eave_height" "expansion_joint" "gen_block_wall_ht") ("clear_span" "typical_endwall_yes" "bearing_frame_left" "by_pass_left" "306" "5@6000" "10@6000" "60000" "30000" "6000" "0" "2500"))
    clear_span_dialog_details
    (("building_width" "ridge_distance" "frame_profile" "eave_height_left" "ridge_slope_left" "girt_spacings_left" "purlin_spacings_left" "eave_height_right" "ridge_slope_right" "girt_spacings_right" "purlin_spacings_right") ("30000" "15000" "symmetrical" "6000" "1" "10@1000" "10@1500" "6000" "1" "10@1000" "10@1500"))
    left_end_column_size
    ("Ipea-200" "Ipea-200" "Ipea-200" "Ipea-200" "Ipea-200" "Ipea-200")


    But my lisp is removing the double quote inside the list and writing like this as a text file.

    main_input_building_details
    ((frame_type typical_endwall endwall_type_left endwall_girt_type_left corner_column_left_endwall endwall_column_spacings_left bay_spacings_sidewall building_length building_width eave_height expansion_joint gen_block_wall_ht) (clear_span typical_endwall_yes bearing_frame_left by_pass_left 306 5@6000 10@6000 60000 30000 6000 0 3000))
    clear_span_dialog_details
    ((building_width ridge_distance frame_profile eave_height_left ridge_slope_left girt_spacings_left purlin_spacings_left eave_height_right ridge_slope_right girt_spacings_right purlin_spacings_right) (30000 15000 symmetrical 6000 1 10@1000 10@1500 6000 1 10@1000 10@1500))
    left_end_column_size
    (Ipea-200 UB-203 UB-203 UB-203 Ipea-200 Ipea-200)

Similar Threads

  1. I need to send the output of the "LIST" command to a text file
    By evaristor in forum AutoCAD Beginners' Area
    Replies: 12
    Last Post: 1st Sep 2009, 06:57 pm
  2. Font file is not on the list
    By Polly in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 18
    Last Post: 25th Jun 2009, 06:28 pm
  3. Change popup list contents from one list to another
    By The Buzzard in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 4th Mar 2009, 05:22 am
  4. File, Open, List
    By GMiller in forum AutoCAD Beginners' Area
    Replies: 5
    Last Post: 26th Sep 2008, 08:40 pm
  5. list-write to file??
    By stoobydale in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 7th Jun 2005, 07:06 am

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