Old LISP routines and 2017 CAD

Old LISP routines and 2017 CAD

igukovsk
Explorer Explorer
4,423 Views
8 Replies
Message 1 of 9

Old LISP routines and 2017 CAD

igukovsk
Explorer
Explorer

I currently using AutoCAD 2016 and just got an offer upgrade to AutoCAD 2017. I heavily rely on LISP and want to make sure that my LISP routines will work the same way as they work now with 2016 CAD. Thank you in advance!

0 Likes
Accepted solutions (3)
4,424 Views
8 Replies
Replies (8)
Message 2 of 9

hmsilva
Mentor
Mentor
Accepted solution

@igukovsk wrote:

I currently using AutoCAD 2016 and just got an offer upgrade to AutoCAD 2017. I heavily rely on LISP and want to make sure that my LISP routines will work the same way as they work now with 2016 CAD. Thank you in advance!


Hello igukovsk and welcome to the Autodesk Community!

 

You will have to test the routines in AC2017....

 2017 New Commands and System Variables  Some new commands and variables were introduced...

 

Instal a trial version, and test your routines...

 

Hope this helps,
Henrique

EESignature

Message 3 of 9

dgorsman
Consultant
Consultant

Right - while most generic LISP will continue to work, your routines may have version or other references which require tweaking (e.g. ObjectDBX).  The only way any of us can tell if our own LISP routines will work in a new version is to test them ourselves.  All part and parcel of the upgrade process.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 4 of 9

Anonymous
Not applicable

Speaking of which, the code below used to work perfectly until 2016, now on 2017 it is not working: the second hatch where the number of desired vertical lins is more than 1 generates an error, saying the point sits on the object. Not sure why, any help fixing this much appreciated.

 

 

 

; Square divide
; Divides a virtual room into n x m rows and columns all on defpoints
(defun c:sd ()

 

; set hatch parameters
(setvar "CMDECHO" 0)
(setvar "HPANG" 0)
(setvar "HPNAME" "U")
(setvar "HPDOUBLE" 0)

 

;Save initial state
(setq ExistingLayer (getvar "CLAYER"))
(setq ExistingOSMODE (getvar "OSMODE"))
(setvar "OSMODE" 33)

 

; get corners
(setq pt1 (getpoint "\nPick lower left corner: "))
(setq pt3 (getpoint "\nPick upper right corner: "))
(setvar "OSMODE" 0)

 

; calculate points 2 and 4
(setq
pt2 (list (car pt3) (cadr pt1))
pt4 (list (car pt1) (cadr pt3))
Horizontal_Distance (distance pt1 pt2)
Verticall_Distance (distance pt1 pt4)
Num_Horizontal_Lines (getint "\nNumber of horizontal division lines: ")
Num_Verticall_Lines (getint "\nNumber of vertical division lines: ")
);setq

 

; Sit on DEFPOINTS, unlock first in case isolated
(command "layer" "m" "DEFPOINTS" "")
(command "layer" "U" "DEFPOINTS" "")

 

; Draw the vitual polyline
(command "pline" pt1 pt2 pt3 pt4 "c")
(setq vitual_Polyline (entlast))

 

(cond
((= Num_Horizontal_Lines 1)
(setq Middle_pt1 (polar pt1 (* pi 0.5) (/ Verticall_Distance 2)) )
(setq Middle_pt2 (polar pt2 (* pi 0.5) (/ Verticall_Distance 2)) )
(command "line" Middle_pt1 Middle_pt2 "")
);
((> Num_Horizontal_Lines 1)
(setq hatch_HORT (* Num_Horizontal_Lines 2))
(setq hatch_OHOR (/ Verticall_Distance hatch_HORT))
(setq hatch_HINS (polar pt1 (* pi 0.5) hatch_OHOR))
(command "-HATCH" "P" "" "0" (* hatch_OHOR 2) "N" "O" "S" hatch_HINS "" "S" vitual_Polyline "" "")
(command "explode" "L")
);
);cond
(cond
((= Num_Verticall_Lines 1)
(setq Middle_pt1 (polar pt1 0 (/ Horizontal_Distance 2)) )
(setq Middle_pt2 (polar pt4 0 (/ Horizontal_Distance 2)) )
(command "line" Middle_pt1 Middle_pt2 "")
);
((> Num_Verticall_Lines 1)
(setq hatch_VERT (* Num_Verticall_Lines 2))
(setq hatch_OVER (/ Horizontal_Distance hatch_VERT))
(setq hatch_VINS (polar pt1 0 hatch_OVER))
(command "-HATCH" "P" "" "90" (* hatch_OVER 2) "N" "O" "S" hatch_VINS "" "S" vitual_Polyline "" "")
(command "explode" "L")
);
);cond

; Cleanup
(command "erase" vitual_Polyline "")

; Restore
(command "layer" "s" ExistingLayer "")
(setvar "OSMODE" ExistingOSMODE)
(princ)
);defun
;;-----------------------------------------------------------------------------

0 Likes
Message 5 of 9

Anonymous
Not applicable

bump 

0 Likes
Message 6 of 9

igukovsk
Explorer
Explorer
Accepted solution

Try this. It should work now with CAD 2017

 

; Square divide
; Divides a virtual room into n x m rows and columns all on defpoints
(defun c:sd ()

 

; set hatch parameters
(setvar "CMDECHO" 0)
(setvar "HPANG" 0)
(setvar "HPNAME" "U")
(setvar "HPDOUBLE" 0)

 

;Save initial state
(setq ExistingLayer (getvar "CLAYER"))
(setq ExistingOSMODE (getvar "OSMODE"))
(setvar "OSMODE" 33)

 

; get corners
(setq pt1 (getpoint "\nPick lower left corner: "))
(setq pt3 (getpoint "\nPick upper right corner: "))
(setvar "OSMODE" 0)

 

; calculate points 2 and 4
(setq
pt2 (list (car pt3) (cadr pt1))
pt4 (list (car pt1) (cadr pt3))
Horizontal_Distance (distance pt1 pt2)
Verticall_Distance (distance pt1 pt4)
Num_Horizontal_Lines (getint "\nNumber of horizontal division lines: ")
Num_Verticall_Lines (getint "\nNumber of vertical division lines: ")
);setq

 

; Sit on DEFPOINTS, unlock first in case isolated
(command "layer" "m" "DEFPOINTS" "")
(command "layer" "U" "DEFPOINTS" "")

 

; Draw the vitual polyline
(command "pline" pt1 pt2 pt3 pt4 "c")
(setq vitual_Polyline (entlast))

 

(cond
((= Num_Horizontal_Lines 1)
(setq Middle_pt1 (polar pt1 (* pi 0.5) (/ Verticall_Distance 2)) )
(setq Middle_pt2 (polar pt2 (* pi 0.5) (/ Verticall_Distance 2)) )
(command "line" Middle_pt1 Middle_pt2 "")
);
((> Num_Horizontal_Lines 1)
(setq hatch_HORT (* Num_Horizontal_Lines 2))
(setq hatch_OHOR (/ Verticall_Distance hatch_HORT))
(setq hatch_HINS (polar pt1 (* pi 0.5) hatch_OHOR))
(command "-HATCH" "P" "U" "0" (* hatch_OHOR 2) "N" "O" "S" hatch_HINS "" "S" vitual_Polyline "" "")
(command "explode" "L")
);
);cond
(cond
((= Num_Verticall_Lines 1)
(setq Middle_pt1 (polar pt1 0 (/ Horizontal_Distance 2)) )
(setq Middle_pt2 (polar pt4 0 (/ Horizontal_Distance 2)) )
(command "line" Middle_pt1 Middle_pt2 "")
);
((> Num_Verticall_Lines 1)
(setq hatch_VERT (* Num_Verticall_Lines 2))
(setq hatch_OVER (/ Horizontal_Distance hatch_VERT))
(setq hatch_VINS (polar pt1 0 hatch_OVER))
(command "-HATCH" "P" "U" "90" (* hatch_OVER 2) "N" "O" "S" hatch_VINS "" "S" vitual_Polyline "" "")
(command "explode" "L")
);
);cond

; Cleanup
(command "erase" vitual_Polyline "")

; Restore
(command "layer" "s" ExistingLayer "")
(setvar "OSMODE" ExistingOSMODE)
(princ)
);defun
;;------------------------------------------------​-----------------------------

Message 7 of 9

Anonymous
Not applicable
Accepted solution

Thank you very much igukovsk it now works perfectly 🙂

0 Likes
Message 8 of 9

Anonymous
Not applicable

Hello! I am working on a student project at my University and i try to use old Lisp routines (Mechanical Desktop 2008) in Autocad Mechanical 2016. I am new to this (absolute beginner in Autodesk) and i tried to import the Lisp files but the are not working. Is there a way to solve the problem?

The routines are very important for my Thesis and i cant rebuild them by myself.

Thank you in advance!

Michael

0 Likes
Message 9 of 9

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... i tried to import the Lisp files but the are not working.....


Welcome to these Forums!

 

More information is needed -- what does "not working" mean?  You are not able to load them?  You can load them, but when you call for them, the [I'll assume you're talking about] command names are not recognized?  The commands are recognized but they don't do what you expect?  They do something you don't expect?  Are there any error messages?  Etc., etc.

 

There is a dedicated Forum for AutoCAD Mechanical.  If you go there, and say which routines you're trying to use, someone may be familiar with them, and perhaps with what may be needed to make them work in newer versions, or whether there's no hope, or whether something already in the program will do what they did, and so on.

Kent Cooper, AIA
0 Likes