Author Topic: WHat is this error mean?  (Read 3962 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
WHat is this error mean?
« on: August 13, 2014, 03:32:00 AM »
While runing a lisp some times gives this error
Code: [Select]
** Error: bad DXF group: (10) **

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: WHat is this error mean?
« Reply #1 on: August 13, 2014, 03:48:08 AM »
Perhaps you have a point value that is/gets set to nil.
Code: [Select]
(setq point nil)
(cons 10 point) => (10)

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: WHat is this error mean?
« Reply #2 on: August 13, 2014, 06:11:22 AM »
This is the part of code which case this crash
Code: [Select]
(defun makeline (str end Ltp lyr )
  (entmake (list (cons 0 "LINE") ; ***
               (cons 6 Ltp) ; Linetype name (present if not BYLAYER)
               (cons 8 lyr) ; Layer
               (cons 10 str) ; Start Point
               (cons 11 end) ; End Point
               (cons 39 0.0) ; Thickness (optional) default = 0
               (cons 62 256) ; Color number (present if not BYLAYER);
               (cons 210 (list 0.0 0.0 1.0)))))

(defun DVD ( dp1 dp2 n sc / DSD I K O SC )  ;(DVD dp1 dp2 n sc)
  (makeline dp1 dp2  "Continuous" "S-BARS-SECT-VERT") 
  (setq o (entlast))
  (setq n (- n 1))
  (setq dsd (/ (distance dp1 dp2) n))
  (setq i dsd)
  (repeat n (entmake (append (list '(0 . "INSERT")'(2 . "SS") '( 8 . "S-BARS-SECT-VERT") (cons 10 (vlax-curve-getpointatdist o i)))
     (mapcar '(lambda (k) (cons k sc)) (list 41 42 43)))) (setq i (+ dsd i)))
  (command "_.Erase" "last" "")
  (command "_.Erase" o "")
  )
)

When variable n=10 gives the error
Code: [Select]
(and (setq p1 (getpoint "\n Pick point"))
(setq p2 (getpoint "\n Pick point"))
(DVD p1 p2 10 16)
)
« Last Edit: August 13, 2014, 08:08:40 AM by HasanCAD »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: WHat is this error mean?
« Reply #3 on: August 13, 2014, 07:09:29 AM »
I'll guess.
What is the makeline function?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: WHat is this error mean?
« Reply #4 on: August 13, 2014, 07:13:16 AM »
This code is a perfect demonstration of why problem code should be posted with a description of what the poster thinks the code is doing ... a description of the process, not the code.

added:
And the first thing you could do is check the matching Parenthesis

added:
Which version of AutoCAD are you using?
« Last Edit: August 13, 2014, 07:20:30 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: WHat is this error mean?
« Reply #5 on: August 13, 2014, 08:09:57 AM »
This works for me .. as I assume you intended.
Note I've used the command-s for AC2015 .. revise to command to suit
Code - Auto/Visual Lisp: [Select]
  1. (defun dvd (dp1 dp2 nodes scale / add-local-vars-later)
  2.            ;|
  3.      Insert block at <scale>, <node> times
  4.      spaced equally between selected points
  5.      with no insert at selected points
  6. |;
  7.   (makeline dp1 dp2 "Continuous" "S-BARS-SECT-VERT")
  8.   (setq o                   (entlast)
  9.         spacing             (/ (distance dp1 dp2) (1+ nodes))
  10.         incrementeddistance spacing
  11.   )
  12.   (repeat nodes
  13.     (entmake
  14.       (append (list '(0 . "INSERT")
  15.                     '(2 . "SS")
  16.                     '(8 . "S-BARS-SECT-VERT")
  17.                     (cons 10 (vlax-curve-getpointatdist o incrementeddistance))
  18.               )
  19.               (mapcar '(lambda (k) (cons k scale)) (list 41 42 43))
  20.       )
  21.     )
  22.     (setq incrementeddistance (+ spacing incrementeddistance))
  23.   )
  24.   (command-s "_.Erase" o "")
  25.   (princ)
  26. )
  27.  


Code - Auto/Visual Lisp: [Select]
  1.  
  2. ;; ASSUMES block "SS" exists in drawing.
  3. (defun makeline (dp1 dp2 lt l)
  4.   (command-s "_.LINE" dp1 dp2 "")
  5. )
  6.  
  7. (if (and (setq dp1 (getpoint "\n Pick point"))
  8.          (setq dp2   (getpoint dp1 "\n Pick point")
  9.                nodes 8                  ; block inserts @ distance/(nodes+1)
  10.                scale 16
  11.          )
  12.     )
  13.   (dvd dp1 dp2 nodes scale)
  14. )
  15.  
« Last Edit: August 13, 2014, 08:28:55 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: WHat is this error mean?
« Reply #6 on: August 13, 2014, 08:29:15 AM »
I am using CAD2014
Makeline its entmake line "added to Reply #2"

We draft strucural drawings, one of the task is draw details of column section and arranging the bars in this section (see attached)
This part of code inserts bars (lisp attached).
the lisp crashed when side bars is 10.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: WHat is this error mean?
« Reply #7 on: August 13, 2014, 08:55:22 AM »
 I see what your intent is now ( from your posted code)

How often do you get the error ?
How many people use the routine ?

Can you load it from the VLIDE ( as lisp code) with Debug->BreakOnError toggled on.
Then select Last Break Source when you get an error

added;
If you do this you will be able to investigate the variable values at the time of the error.
« Last Edit: August 13, 2014, 09:04:03 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: WHat is this error mean?
« Reply #8 on: August 13, 2014, 10:58:24 AM »
The problem is probably caused by a rounding issue:
(setq dsd (/ lenLine 9))
(+ dsd dsd dsd dsd dsd dsd dsd dsd dsd) => can be bigger than lenLine due to rounding errors.

Why not replace this:
Code: [Select]
(repeat n
  ...
)
(command "_.Erase" "last" "")
With:
Code: [Select]
(repeat (1- n)
  ...
)

Alternatively you can use ((vlax-curve-getendpoint o) or (vlax-get o 'endpoint) for the endpoint.
« Last Edit: August 13, 2014, 11:01:27 AM by roy_043 »

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: WHat is this error mean?
« Reply #9 on: August 13, 2014, 12:50:05 PM »
This works for me .. as I assume you intended.
Note I've used the command-s for AC2015 .. revise to command to suit
Code - Auto/Visual Lisp: [Select]
  1. (defun dvd (dp1 dp2 nodes scale / add-local-vars-later)
  2.            ;|
  3.      Insert block at <scale>, <node> times
  4.      spaced equally between selected points
  5.      with no insert at selected points
  6. |;
  7.   (makeline dp1 dp2 "Continuous" "S-BARS-SECT-VERT")
  8.   (setq o                   (entlast)
  9.         spacing             (/ (distance dp1 dp2) (1+ nodes))
  10.         incrementeddistance spacing
  11.   )
  12.   (repeat nodes
  13.     (entmake
  14.       (append (list '(0 . "INSERT")
  15.                     '(2 . "SS")
  16.                     '(8 . "S-BARS-SECT-VERT")
  17.                     (cons 10 (vlax-curve-getpointatdist o incrementeddistance))
  18.               )
  19.               (mapcar '(lambda (k) (cons k scale)) (list 41 42 43))
  20.       )
  21.     )
  22.     (setq incrementeddistance (+ spacing incrementeddistance))
  23.   )
  24.   (command-s "_.Erase" o "")
  25.   (princ)
  26. )
  27.  


Code - Auto/Visual Lisp: [Select]
  1.  
  2. ;; ASSUMES block "SS" exists in drawing.
  3. (defun makeline (dp1 dp2 lt l)
  4.   (command-s "_.LINE" dp1 dp2 "")
  5. )
  6.  
  7. (if (and (setq dp1 (getpoint "\n Pick point"))
  8.          (setq dp2   (getpoint dp1 "\n Pick point")
  9.                nodes 8                  ; block inserts @ distance/(nodes+1)
  10.                scale 16
  11.          )
  12.     )
  13.   (dvd dp1 dp2 nodes scale)
  14. )
  15.  

When replace your subroutine DVD with mine error comes(attached)

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: WHat is this error mean?
« Reply #10 on: August 13, 2014, 12:50:54 PM »
The problem is probably caused by a rounding issue:
(setq dsd (/ lenLine 9))
(+ dsd dsd dsd dsd dsd dsd dsd dsd dsd) => can be bigger than lenLine due to rounding errors.

Why not replace this:
Code: [Select]
(repeat n
  ...
)
(command "_.Erase" "last" "")
With:
Code: [Select]
(repeat (1- n)
  ...
)

Alternatively you can use ((vlax-curve-getendpoint o) or (vlax-get o 'endpoint) for the endpoint.

solved the problem let me test on another machines

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: WHat is this error mean?
« Reply #11 on: August 13, 2014, 05:42:54 PM »
The problem is probably caused by a rounding issue:
(setq dsd (/ lenLine 9))
(+ dsd dsd dsd dsd dsd dsd dsd dsd dsd) => can be bigger than lenLine due to rounding errors.

Why not replace this:
Code: [Select]
(repeat n
  ...
)
(command "_.Erase" "last" "")
With:
Code: [Select]
(repeat (1- n)
  ...
)

Alternatively you can use ((vlax-curve-getendpoint o) or (vlax-get o 'endpoint) for the endpoint.

solved the problem let me test on another machines


If you look at my code, I don't draw and erase the last block, so my algorithm removed that issue.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: WHat is this error mean?
« Reply #12 on: August 13, 2014, 05:50:14 PM »
< ... >
When replace your subroutine DVD with mine error comes(attached)

When you run my code in isolation does the error occur  ?
Remember to change the command-s to command or vla-cmdf


I noticed you don't have an error routine in the code.
You should have at least something like this :

Code - Auto/Visual Lisp: [Select]
  1. (defun *error* (s) (vl-bt) (princ))
  2.  

Can you please do that and try again.
« Last Edit: August 13, 2014, 05:57:58 PM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: WHat is this error mean?
« Reply #13 on: August 16, 2014, 06:49:26 AM »
Can you please do that and try again.
Sorry for being late

When you run my code in isolation does the error occur  ?
working very good but I made some changes
Code - Auto/Visual Lisp: [Select]
  1. (defun dvd (dp1 dp2 nodes scale / add-local-vars-later)
  2.            ;|
  3.      Insert block at <scale>, <node> times
  4.      spaced equally between selected points
  5.      with no insert at selected points
  6. |;
  7.   (makeline dp1 dp2 "Continuous" "0")
  8. (setq o                         (entlast)
  9.       ds                        (distance dp1 dp2)      ;added
  10.       spacing                   (/ ds (1- nodes))       ;instead of (1+ nodes)
  11.       incrementeddistance       spacing
  12. )
  13.   (repeat nodes
  14.     (if (or                                             ;Added
  15.           (> ds incrementeddistance)
  16.           (= ds incrementeddistance)
  17.           )
  18.     (progn
  19.       (entmake
  20.       (append (list '(0 . "INSERT")
  21.                     '(2 . "SS")
  22.                     '(8 . "S-BARS-SECT-VERT")
  23.                     (cons 10 (vlax-curve-getpointatdist o incrementeddistance))
  24.               )
  25.               (mapcar '(lambda (k) (cons k scale)) (list 41 42 43)))
  26.       )
  27.       (setq incrementeddistance (+ spacing incrementeddistance))
  28.       )
  29.       )
  30.     )
  31.   (vl-cmdf "_.Erase" o "")                              ; instead of command-s
  32.   (princ)
  33. )


I noticed you don't have an error routine in the code.
You should have at least something like this :

Code - Auto/Visual Lisp: [Select]
  1. (defun *error* (s) (vl-bt) (princ))
  2.  
There is an error routine (3rd subroutine in main lisp).
« Last Edit: August 16, 2014, 07:08:25 AM by HasanCAD »

ur_naz

  • Newt
  • Posts: 68
  • Made in Ukraine
Re: WHat is this error mean?
« Reply #14 on: August 17, 2014, 07:03:39 AM »
I am using CAD2014
Makeline its entmake line "added to Reply #2"

We draft strucural drawings, one of the task is draw details of column section and arranging the bars in this section (see attached)
This part of code inserts bars (lisp attached).
the lisp crashed when side bars is 10.
Don't forget to add "_" to command options such as
Code - Auto/Visual Lisp: [Select]
  1. (vl-cmdf "_.erase" "_last" "")
etc