Author Topic: error: bad argument type: numberp: nil  (Read 1272 times)

0 Members and 1 Guest are viewing this topic.

udaafri

  • Mosquito
  • Posts: 16
error: bad argument type: numberp: nil
« on: April 11, 2022, 07:53:39 PM »
I've code like this
Quote
; (ROUND NUM FRAC) returns NUM rounded to the nearest FRAC.
; By Duff Kurland - Autodesk, Inc. August 22, 1986
(defun round (num frac / over half)
  (setq half (/ frac 2.0))
  (setq over (rem num frac)) ; Get remainder
  (if (>= over half)
    (+ num frac (- over)) ; Round up
    (- num over) ; Round down
    )
  )

(setq PT0 (getpoint "\nTentukan Titik Arah pertama:"))
(setq PT1 (getpoint PT0 "\nTentukan Titik Arah kedua:"))
(setq ANG (angle PT0 PT1))
(setq ang2 (round (- (atof (angtos ANG 0 2)) 90.0) 0.001))
(if (minusp ang2)
  (setq ang2 (round (+ ang2 360.0) 0.1))
  (setq ang2 (round (ang2) 0.1))
  );if
(COMMAND "-iNSERT" "RoofMaterial" (list 71241.0400 20075.6073) 1 1 ang2)

Sometimes running well and sometimes get error: bad argument type: numberp: nil, when using looping.

Quote
-iNSERT Enter block name or [?] <RoofMaterial>: RoofMaterial
Units: Millimeters   Conversion:    1.0000
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]:
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>: 1 Enter Y
scale factor <use X scale factor>: 1
Specify rotation angle <0>: 180.0000000000000
Command: ; error: bad argument type: numberp: nil

how to solve this case?



d2010

  • Bull Frog
  • Posts: 326
Re: error: bad argument type: numberp: nil
« Reply #1 on: April 12, 2022, 01:05:54 AM »
I transpiler the your-programe to debugversion(.jc_aro.lsp
You search inside the source "pp_udaafri_jc_aro10.lsp" , you search the var
Hidos=, after you type the command  C:pid0476 or C:Q2
Code - Auto/Visual Lisp: [Select]
  1. (Prompt "\nCommand.com=C:Q2[enter] or C:Q2\n")
  2. (defun C:Q2() ;_ASSERT_OK
  3.  (setq _ax (nn_vmload "\nSpecify the number of queens[3..43]="))
  4.  (princ "\nEnd")  
  5. $rr)
  6. (defun nn_vmload(monoumb / $rr pt0 pt1 ang1 an2 angf bna entb name)  
  7.  (setq;|a67118906|;
  8.          pt0 (jc_aro10 (list "C001getpoint" "\nTentukan Titik Arah pertama:"))
  9.          pt1 (jc_aro10 (list "C002getpoint" PT0 "\nTentukan Titik Arah kedua:"))
  10.          angf (jc_aro10 (list "C003angle" pt0 pt1))
  11.          ang2 (if (jc_aro10 (list "C004minusp" angf)) (jc_aro10 (list "C005dfn_round" (+ angf 360) 0.1)) (jc_aro10 (list "C006dfn_round" angf 0.1)))
  12.          entb (jc_aro10 (list "C007entsel" "\nPick Select the Block="))
  13.          name (if entb (cdr (jc_aro10 (list "C008assoc" 2 (jc_aro10 (list "C009entget" (car entb)))))) "RoofMaterial")) (prompt "\nBlock/Name=") (prompt name) (prompt "\nHit a key to continue") (jc_aro10 (list "C010grread")) (command "-iNSERT" name (list 71241.0400 20075.6073) 1 1 ang2)
  14. $rr)
  15. (defun dfn_round (num frac / $rr over half)
  16.  (setq
  17.          half (* frac 0.5)
  18.          over (rem num 2.0)
  19.          $rr (if (>= over half) (* (- (+ num frac) over)) (- num over)))
  20. $rr)
  21. (princ (setvar "ModeMacro" "Call-StackError=(C:pid0476)"))
  22. (defun C:pid0476(/ )
  23.  (princ "Pidgen.dll=") (princ pidgen.dll)
  24.  (princ "\nHiStack=") (princ pidgen10rsp)
  25.  (princ "\nHiDos=") (princ setmypid)
  26. )
  27. (setq pidgen10rsp nil pidgen.dll 0)
  28. (defun jc_aro10(loopwne  / rom subf mypid adc)
  29.    (setq mypid (car loopwne) adc 0)
  30.    (setq setmypid mypid subf (substr mypid 5))
  31.    (if (/= (car pidgen10rsp) subf)  (setq adc 1 pidgen10rsp (cons subf pidgen10rsp)))
  32.    (setq rom (apply (read subf) (cdr loopwne)))
  33.    (if (= adc 1) (setq pidgen10rsp (cdr pidgen10rsp)))
  34.    (setq pidgen.dll (1+ pidgen.dll))
  35. rom)
:crazy2:


« Last Edit: April 12, 2022, 10:14:19 AM by d2010 »

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2151
  • class keyThumper<T>:ILazy<T>
Re: error: bad argument type: numberp: nil
« Reply #2 on: April 12, 2022, 03:23:20 AM »
I transpiler the your-programe to debugversion(.jc_aro.lsp
You search inside the source "pp_udaafri_jc_aro10.lsp" , you search the var
Hidos=, after you type the command  C:pid0476 or C:Q2
Code - Auto/Visual Lisp: [Select]
  1. $rr)
  2.  



Rather than subject the original poster ( and others ) to a couple pages of your ramblings, that do nothing to assist the original poster with the cause and solution for his issues, how about you actually provide a post with value for a change.
« Last Edit: April 12, 2022, 03:31:39 AM by kdub »
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

udaafri

  • Mosquito
  • Posts: 16
Re: error: bad argument type: numberp: nil
« Reply #3 on: April 12, 2022, 06:12:41 AM »
I will provide a post with value for a change to the next post.
I just post some script when found an error from my whole code. 

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: error: bad argument type: numberp: nil
« Reply #4 on: April 12, 2022, 07:44:44 AM »
I will provide a post with value for a change to the next post.
Kerry was not referring to your thread so your post is okay.

Your variable 'ang2' is not a function to wrap it separately, so
Change this:
(setq ang2 (round (ang2) 0.1))
with this:
(setq ang2 (round ang2 0.1))

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2151
  • class keyThumper<T>:ILazy<T>
Re: error: bad argument type: numberp: nil
« Reply #5 on: April 12, 2022, 05:13:44 PM »
I will provide a post with value for a change to the next post.
I just post some script when found an error from my whole code.

udaafri, I have no dispute with your post.

A bit of additional info would be helpful.
Which version of AutoCAD do you use ??
What are your UnitSettings ?

You say you have trouble when looping. ... How are you looping. ?

You  prompt for  :
'Determine the first Direction Point' and
'Determine the second Direction Point'
but have the insertPoint hard-coded in the Command. .. is this your usual practice ?

Regards,
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2151
  • class keyThumper<T>:ILazy<T>
Re: error: bad argument type: numberp: nil
« Reply #6 on: April 12, 2022, 06:02:22 PM »
This seems ok for me in 2022, 2023 with the units previously posted.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:testit ( / )
  2.   ;; I assume PT0 is NOT INSERT_Point) and prompt should be 'Determine the first Direction Point Origin'
  3.   (setq PT0  (getpoint "\nTentukan Titik Arah pertama:")  ; 'Determine the first Direction Point'
  4.         PT1  (getpoint PT0 "\nTentukan Titik Arah kedua:") ; 'Determine the second Direction Point'
  5.         ANG  (angle PT0 PT1)
  6.         ang2 (round (- (atof (angtos ANG 0 2)) 90.0) 0.001)
  7.   )
  8.   (if (minusp ang2)
  9.     (setq ang2 (round (+ ang2 360.0) 0.1))
  10.     (setq ang2 (round ang2 0.1))
  11.   )
  12.   (command "-INSERT"
  13.            "W-FIELD"
  14.                ;;(list 71241.0400 20075.6073)
  15.            (list 200.000 500.000)
  16.            "X" 1.0
  17.            "" ""
  18.            ang2
  19.   )
  20.   (princ)
  21. )
  22.  
  23.  
  24.  
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

udaafri

  • Mosquito
  • Posts: 16
Re: error: bad argument type: numberp: nil
« Reply #7 on: April 12, 2022, 08:54:46 PM »
Which version of AutoCAD do you use ?
AutoCAD 2011
What are your UnitSettings ?
Default settings for units
Here's the code before.
I've found the problem, why become error: bad argument type: numberp: nil?
It occurs because removing the same data in the list does not work well.
;(setq abc (LM:LISTDUPES DistList))
So, I change with Fuzz and works.
(setq abc (LM:UniqueFuzz DistList 0.01))
I don't get errors again.
@kdub
Thanks  8-).

Code: [Select]
(repeat (sslength SelPline)
  (setq bblistpoint
(mapcar '(lambda (x) x) (bbrotate (ssname SelPline i)))
  )
;memastikan nilai selalu lebih kecil dari Y
  (setq DistList (vl-sort (GetDistances bblistpoint) '<))
;penyakitnya disini karena menghasilkan nilai nil
;(setq abc (LM:LISTDUPES DistList))
  (setq abc (LM:UniqueFuzz DistList 0.01))
  (setq Point1 (car abc))
  (setq Point2 (cadr abc))
  (setq i (1+ i))
  (setq NewList (append (list PXY)
(list RRL)
(list group)
(list (list material))
)
  )
  (setq InsPointList (cons (cons PtMin NewList) InsPointList))
)
(setq InsObjList (reverse InsPointList))
(repeat (length InsObjList)
  (setq DataInsert (nth j InsObjList))
  (if (minusp (round (- (atof (angtos ANG 0 2)) 90.0) 0.1))
    (setq ang2 (+ 360.0 (round (- (atof (angtos ANG 0 2)) 90.0) 0.1)))
    (setq ang2 (round (- (atof (angtos ANG 0 2)) 90.0) 0.1))
  ) ;if
;(setq ang2 (round (- (atof (angtos ANG 0 2)) 90.0) 0.001))
  (COMMAND "-iNSERT" "RoofMaterial" (car DataInsert) 1 1 ang2)
)


I will provide a post with value for a change to the next post.
I just post some script when found an error from my whole code.

udaafri, I have no dispute with your post.

A bit of additional info would be helpful.
Which version of AutoCAD do you use ??
What are your UnitSettings ?

You say you have trouble when looping. ... How are you looping. ?

You  prompt for  :
'Determine the first Direction Point' and
'Determine the second Direction Point'
but have the insertPoint hard-coded in the Command. .. is this your usual practice ?

Regards,


kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2151
  • class keyThumper<T>:ILazy<T>
Re: error: bad argument type: numberp: nil
« Reply #8 on: April 12, 2022, 09:10:22 PM »
great result !
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.