Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AutoCAD 2015 Lisp routine VVC: Internal error

2 REPLIES 2
Reply
Message 1 of 3
ruddster
1276 Views, 2 Replies

AutoCAD 2015 Lisp routine VVC: Internal error

The following lisp routine is used to draw channel sections in previous AutoCAD versions (AutoCAD 2014 works with no problems).

 

;;;   DIBUJA SECCIONES DE CANALES ESTRUCTURALES


;;;
(defun draw_pline (/ dxdy)

   ;; if start point not defined, then get one
   ;; see tube for why this check is useful
   (if (null ip)
       (setq IP (getpoint "\nInsertion Point: "))
   )
   (command "pline" ip 
      (mapcar 
        '(lambda (dxdy)

            ;; if the entry from the data table is longer than
            ;; an x-y-z list, then execute the command(s) at the
            ;; the beginning of the entry, 
            ;; then truncate the entry to x-y-z
            (while  (> (length DXDY) 3)
                    (command (car DXDY))
                    (setq DXDY (cdr DXDY))
            )

            ;; generate a point based on dx dy dz 
            ;; from the last point
            (command
               (setq IP
                  (mapcar '(lambda (i j) (+ i (eval j)))
                           IP 
                           dxdy
                  )
               )
            )
         )
         data_table
      );mapcar
   );commnd
);draw_pline
;;;   draw a Channel
;;;   starts at lower left corner, runs counterclockwise
(defun c:channel (/ os cl D E F H CHOICE dms x pnt1 pnt2 a d1 h1 d2 
                    pt3 pt4 pt5 pt6 pt7 pt8)
   (graphscr)
   (setvar "cmdecho" 1)
   (setq os (getvar "osmode"))
   (setq cl (getvar "clayer"))
   (setvar "osmode" 0)
   (command "layer" "make" "channel" "")
   (command "layer" "set" "channel" "")
   (command "layer" "C" "6" "" "")
   
   (setq
      D (getdist "\nDepth            ==> ")
      E (getdist "\nWeb Thickness    ==> ")
      F (getdist "\nFlange Width     ==> ")
      H (getdist "\nAvg Flange Thk   ==> "))
   (setq
      D ( * D 0.0254)
      E ( * E 0.0254)
      F ( * F 0.0254)
      H ( * H 0.0254))

 (prompt
   "\nOK-What do you want? ESection, EOpen, EBack or EPlan")
   (CHMENU)
)
   (defun CHMENU ()
      (initget "ESection EOpen EBack EPlan Quit2")
      (setq CHOICE (getkword 
      "\nESection/EOpen/EBack/EPlan/Quit2: "))
      (cond
         ((= CHOICE "ESection")
         (ESection)
         )
         ((= CHOICE "EOpen")
         (EOpen)
         )
         ((= CHOICE "EBack")
         (EBack)
         )
         ((= CHOICE "EPlan")
         (EPlan)
         )
         ((= CHOICE "Quit2")
         (OK)
         )
         ((null CHOICE)
         (prompt "\nYou Must Enter ES,EO,EB,EP, or Q!")
         (CHMENU)
         )
      )
   )
   
(defun ESection ()
   ;ESection
   (graphscr)
   (setvar "clayer" "channel")
   (c_draw d e f h)
);CSection
(defun c_draw (d e f h / a b m i L x y data_table ip)
   (setq
      A (- F  E)
      M (* 0.15838444 (/ A 2.0))
      B (- D (* 2 (+ M H)))
      I (atan A (* 2 M))              ; internal angle of arc
      L (- H M)                       ; tangent length of fillet
      Y (polar '(0 0 0) (- (/ pi 2) I) L) 
      X (car Y)                       ; dx of fillet
      Y (cadr Y)                      ; dy of fillet

      data_table
           '((0 D 0)
             (F 0 0)
             ("ARC"  "DIRECTION" 0 (- M H) 0)   
             ((- X) (- Y) 0)
             ("LINE"  (- X A) (- Y (* 2 M)) 0)
             (0 (- B) 0)
             ((- A X) (- Y (* 2 M)) 0)
             ("ARC"  "DIRECTION"  X (- Y) 0)   
             (0 (- L) 0)
             ("LINE"  (- F) 0 0)
            );end table
   );setq
   (draw_pline)
   (redraw)
   (CHMENU)
   )
(defun EOpen ()   
   ;EOpen
   (graphscr)
   (setvar "orthomode" 1)
   (setvar "clayer" "channel")
   (setvar "osmode" 0)
   (setq pnt1 (getpoint "\nEnter First Point  " )) (terpri)
   (setq pnt2 (getpoint "\nEnter Second Point " pnt1 )) (terpri)
   (setq a (angle pnt1 pnt2)) (princ a) (terpri)
   (setq d1 (distance pnt1 pnt2)) (princ d1) (terpri)
   (setq h1 (- H H H))
   (setq d2 (- D D D))
   (setq pt3 (polar pnt2 (+ a (dtr 90)) D))
   (setq pt4 (polar pnt1 (+ a (dtr 90)) D))
   (setq pt5 (polar pnt1 (+ a (dtr 90)) H))
   (setq pt6 (polar pnt2 (+ a (dtr 90)) H))
   (setq pt7 (polar pt4 (+ a (dtr 90)) h1))
   (setq pt8 (polar pt3 (+ a (dtr 90)) h1))
   (command "pline" pnt1 pnt2 pt3 pt4 "close")
   (command "line" pt5 pt6 "")
   (command "line" pt7 pt8 "")
   (redraw)
   (CHMENU)
   )
(defun EBack ()   
   ;EBack
   (graphscr)
   (setvar "orthomode" 1)
   (setvar "clayer" "channel")
   (setvar "osmode" 0)
   (setq pnt1 (getpoint "\nEnter First Point  " )) (terpri)
   (setq pnt2 (getpoint "\nEnter Second Point " pnt1 )) (terpri)
   (setq a (angle pnt1 pnt2)) (princ a) (terpri)
   (setq d1 (distance pnt1 pnt2)) (princ d1) (terpri)
   (setq h1 (- H H H))
   (setq d2 (- D D D))
   (setq pt3 (polar pnt2 (+ a (dtr 90)) D))
   (setq pt4 (polar pnt1 (+ a (dtr 90)) D))
   (setq pt5 (polar pnt1 (+ a (dtr 90)) H))
   (setq pt6 (polar pnt2 (+ a (dtr 90)) H))
   (setq pt7 (polar pt4 (+ a (dtr 90)) h1))
   (setq pt8 (polar pt3 (+ a (dtr 90)) h1))
   (command "pline" pnt1 pnt2 pt3 pt4 "close")
   (command "layer" "make" "web_beyond" "lt" "dashed" "" "C" "8" "" "") (terpri)   
   (command "line" pt5 pt6 "")
   (command "line" pt7 pt8 "")
   (redraw)
   (CHMENU)
   )
(defun EPlan ()   
   ;EPlan
   (graphscr)
   (setvar "orthomode" 1)
   (setvar "clayer" "channel")
   (setq pnt1 (getpoint "\nEnter First Point  " )) (terpri)
   (setq pnt2 (getpoint "\nEnter Second Point " pnt1 )) (terpri)
   (setq a (angle pnt1 pnt2)) (princ a) (terpri)
   (setq pt3 (polar pnt2 (+ a (dtr 90)) F))
   (setq pt4 (polar pnt1 (+ a (dtr 90)) F))
   (setq pt5 (polar pnt1 (+ a (dtr 90)) E))
   (setq pt6 (polar pnt2 (+ a (dtr 90)) E))
   (command "pline" pnt1 pnt2 pt3 pt4 "close")
   (command "layer" "make" "web_beyond" "lt" "dashed" "" "C" "8" "" "") (terpri)
   (command "line" pt5 pt6 "")
   (redraw)
   (CHMENU)
   )
(defun OK ()
(setvar "osmode" os)
(setvar "clayer" cl)
(setvar "cmdecho" 0)
(princ)
(prompt "\nEnd of Channel lisp file. ")
(princ)
);end channel.lsp

 

Now, in AutoCAD 2015, the ESection function is not working. The following error is displayed:

 

Command: (LOAD "CHANNEL")
OK
Command: CHANNEL
layer
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: make
Enter name for new layer (becomes the current layer) <0>: channel Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:
Command: layer
Current layer: "channel"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: set
Enter layer name to make current or <select object>: channel Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:
Command: layer
Current layer: "channel"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: C
New color [Truecolor/COlorbook] : 6
Enter name list of layer(s) for color 6 (magenta) <channel>: Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:
Command:
Depth ==> 12
Web Thickness ==> 5/16
Flange Width ==> 3
Avg Flange Thk ==> 1/2
OK-What do you want? ESection, EOpen, EBack or EPlan
ESection/EOpen/EBack/EPlan/Quit2: es
Insertion Point: pline
Specify start point:
Current line-width is 0.00000000
Specify next point or [Arc/Halfwidth/Length/Undo/Width]: VVC: Internal Error

 

Could anyone help me to get this code working in 2015?

Thanks in advance for all your attentions.

Regards.

2 REPLIES 2
Message 2 of 3
pendean
in reply to: ruddster

You'll get more responses if you also post in the LISP forum: http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/bd-p/130
Message 3 of 3
ruddster
in reply to: pendean

Thank you very much for your suggestion!

Posted in LISP forum.

Regards.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost