fathihvac Posted July 20, 2011 Share Posted July 20, 2011 (edited) Hello, I am working on a lisp that calculates square and round ductwork weight but i got error: bad argument type: stringp nil. Please help KG.LSP Edited July 21, 2011 by fathihvac Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 20, 2011 Share Posted July 20, 2011 Please be more specific, what exactly is the error message shown at the command line? Quote Link to comment Share on other sites More sharing options...
fathihvac Posted July 21, 2011 Author Share Posted July 21, 2011 Thanks i modified my post please check Quote Link to comment Share on other sites More sharing options...
TomN Posted July 22, 2011 Share Posted July 22, 2011 bad argument type: stringp nil means that a string argument was expected but not received. Take a look at the following areas in your code: In your first condition statement near the top of (C:KG), you assign a string to the variable diameter when the length of your text equals 4 characters (but you don't assign anything to variables a and b). When the length equals 7 or 8 characters, you assign portions of the string to variables a and b (but you don't assign anything to diameter). After you exit the cond statement, you call the atoi function on a and again on b, and call atof on diameter. Both atof and atoi expect a string argument, so if you're passing nil to either of these, you will see an error. BTW, near the end of (C:KG), you calculate the weight, convert it to a string, and assign it to a variable weights. Later, in the "TEXT" command call, you supply a variable poids where (I think) you probably intended to pass weights(?). Hope this helps, Tom Quote Link to comment Share on other sites More sharing options...
fathihvac Posted July 23, 2011 Author Share Posted July 23, 2011 Thank very much. I think i found the fault: How to extract real number from the following text representing duct diameter example Ø300,Ø450 ...so reals are 300,450.. Quote Link to comment Share on other sites More sharing options...
pBe Posted July 24, 2011 Share Posted July 24, 2011 (edited) can you provide the pattern for the selected text string. ((eq dimcar 4 ) ((eq dimcar 7 ) ((eq dimcar 8 ) Ø300 is 6 characters in this case... (atoi (substr txt 4)) would be sufficient to give you an Integer or (distof (substr txt 4) 2) for real, where txt is the variable of the selected string. subsequently you can filter the selection with (setq ss (ssget '((0 . "*TEXT")(1 . "%%C*,*-*")))) or whatever symbol you use , that is if the target strings all contains the "Ø" or "-" symbol and judging by the conditions you gave 4 would be Øxxx where string length is actually 6 counting Ø as 3 rather than 1 7 would be xxx-xxx 8 would be xxxx-xxx Also with by using the appropriate function you can derived the Total Length of the entities listed on your cond (cond ((= et "LINE") (tlines)) ((= et "ARC") (tarcs)) ((= et "LWPOLYLINE") (tplines)) ((= et "POLYLINE") (tplines)) ((= et "SPLINE") (tsplines)) using just one function (vlax-curve-getDistAtParam (setq ob (vlax-ename->vla-object (car (entsel)))) (vlax-curve-getEndParam ob) ) you can eliminate all the extra codes you have in there (tplines/tarcs/....) would you mind giving us more info..... Edited July 24, 2011 by pBe Quote Link to comment Share on other sites More sharing options...
fathihvac Posted July 26, 2011 Author Share Posted July 26, 2011 Thank you very much. I am not good at lisp programming so can you write me the whole code . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.