Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AutoCAD 2015 Lisp routine VVC: Internal error

3 REPLIES 3
Reply
Message 1 of 4
ruddster
3579 Views, 3 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.

 

3 REPLIES 3
Message 2 of 4
_gile
in reply to: ruddster

Hi,

 

Try replacing command with command-s within the lambda functions passed as argument to mapcar.

More details on the command-s LISP function here:

http://docs.autodesk.com/ACDMAC/2014/ENU/index.html?url=files/GUID-5C9DC003-3DD2-4770-95E7-7E19A4EE1...



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 4
kirish
in reply to: _gile

Excellent, thanks that worked for a lisp I was trying to get to run.

Message 4 of 4
cbutler1
in reply to: kirish

We get the same error in 2015 that we did not get in all other prior releases (2013 and downward. Don't know if is a problem with 2014).  We have a .NET command defined in the format COPREFIX_DoSomething.  

 

Up until 2015 we were able to define a lisp macro that would be something like this: (defun c:DoSomething () (command "COPREFIX_DoSomething"))

 

Now the above crashes AutoCAD with a fatal error.  This does seem to work: (defun c:DoSomething () (command-s "COPREFIX_DoSomething")).

 

It appears that (Command) has changed somehow and what used to work now breaks.

 

 

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

Post to forums  

Autodesk Design & Make Report

”Boost