Results 1 to 5 of 5

Thread: please notify me which part is wrong

  1. #1
    Member
    Join Date
    2017-12
    Location
    Seoul
    Posts
    2
    Login to Give a bone
    0

    Default please notify me which part is wrong

    I want to draw a simple bolt using AutoLISP
    I wanted to input the diameter of bolt using getreal and to load the data related to the diameter what I input already.
    But Error message occured "stringp nil".
    please notify me which part is wrong



    Code:
    (defun bolt()
      (setq fo (open "C:/Bolt.txt" "r"))
      (while (/= bolt_d data_bolt_1)
        (setq bolt_d (getreal "Enter the diameter of bolt"))
        (setq data_bolt (read-line fo))
        (setq data_bolt_1 (atof (substr data_bolt 2 4)))
        )
      
      (setq bolt_l (getreal (princ (substr data_bolt 76 6))))
      (setq bolt_m (atof (substr data_bolt 6 5)))
      (setq bolt_b (atof (substr data_bolt 11 5)))
      (setq bolt_dkmx (atof (substr data_bolt 16 5)))
      (setq bolt_da (atof (substr data_bolt 21 5)))
      (setq bolt_ds (atof (substr data_bolt 26 5)))
      (setq bolt_e (atof (substr data_bolt 31 5)))
      (setq bolt_lf (atof (substr data_bolt 36 5)))
      (setq bolt_k (atof (substr data_bolt 41 5)))
      (setq bolt_r (atof (substr data_bolt 46 5)))
      (setq bolt_s (atof (substr data_bolt 51 5)))
      (setq bolt_t (atof (substr data_bolt 56 5)))
      (setq bolt_v (atof (substr data_bolt 61 5)))
      (setq bolt_dw (atof (substr data_bolt 66 5)))
      (setq bolt_w (atof (substr data_bolt 71 5)))
    
      (setq pt0 '(0 0))
      (setq pt1 (polar pt0 (/ pi 2) (- (/ bolt_dk 2) (bolt_v))))
      (setq pt2 (polar pt1 (/ pi 4) (/ bolt_v (cos(/ pi 4)))))
      (setq pt3 (polar pt2 0 (- bolt_k bolt_v)))
      (setq pt4 (polar pt3 (/ pi -2) (- (/ bolt_dk 2) (/ bolt_da 2))))
      (setq pt5 (list (+ bolt_lf) (- (- (/ bolt_da 2) (/ bolt_ds 2)))))
      (setq pt6 (polar pt5 0 (- bolt_l (* bolt_P 2))))
      (setq pt7 (polar pt6 (/ pi -4) (/ bolt_v (cos (/ pi 4)))))
      (setq pt8 (polar pt7 (/ pi -2) (- (/ bolt_d 2) (* bolt_P 2))))
      (setq pt9 (polar pt8 (/ pi 2) (/ bolt_dk 2)))
    
      (command "pline" pt0 pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt8 "C")
    
      (setq ss1 (ssget "C" pt7 pt8))
      (command "mirror" ss1 "" pt0 pt8 "N")
      )
    Attached Files Attached Files
    Last edited by sm022453760286; 2017-12-04 at 04:49 PM. Reason: added code tags

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: please notify me which part is wrong

    Did you try editing this in the VLIDE? It will tell you where the error occurs.

    I'll look in just a bit. (Oops, can you post the bolt.txt file?)
    R.K. McSwain | CAD Panacea |

  3. #3
    Member
    Join Date
    2017-12
    Location
    Seoul
    Posts
    2
    Login to Give a bone
    0

    Default Re: please notify me which part is wrong

    Okay. I will attach "bolt.txt" thanks

  4. #4
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: please notify me which part is wrong

    You're never closing the open file.

    I would suggest doing this:

    1. Open the file
    2. Read the entire contents into a list
    3. Close the file

    This way you don't have the file open any longer than needed, reducing the chance of error.

    Now you have the contents of the file in a list, you can iterate this list looking for the match.

    Code:
    (setq fo (open "Bolt.txt" "r"))
      (while (setq a (read-line fo))
        (setq lst (cons a lst))
      )
    (close fo)
    (reverse lst)
    R.K. McSwain | CAD Panacea |

  5. #5
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    559
    Login to Give a bone
    0

    Default Re: please notify me which part is wrong

    I am going to suggest something bold stop what your doing get a dynamic bolt block, just place click set size and length all done.
    Attached Files Attached Files

Similar Threads

  1. Replies: 0
    Last Post: 2014-11-13, 11:07 PM
  2. .dwg in dropbox does not notify us if it is open already
    By dlilborn in forum CAD Management - General
    Replies: 13
    Last Post: 2013-09-24, 07:49 PM
  3. Replies: 0
    Last Post: 2013-05-06, 01:33 AM
  4. Replies: 0
    Last Post: 2013-05-06, 01:28 AM
  5. Elevation Symbol Reporting Wrong Elevation In Wrong Format....
    By aaronrumple in forum Revit - Platform
    Replies: 2
    Last Post: 2009-10-16, 02:23 PM

Posting Permissions

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