PDA

View Full Version : Convert lisp file to vba



jimpcfd
3rd Aug 2010, 01:35 pm
Hi All

i have a lisp file which is a parametric drawing of a folder(envelope) which i wish to convert to VBA, my first question is can it be done and can someone give some tips on the best way to do it etc etc .

lisp code listed below ...



[(princ "\nType FOLDER to start")
(defun c:env ()
(setvar "cmdecho" 0)
(setq UserOS (getvar "osmode"))
(setvar "osmode" 0)
;;======get envelope data=============
(initget 1)
(setq Width (getreal "\nWidth: "))
(initget 1)
(setq Length (getreal "\nLength: "))
(initget 1)
(setq PocketD (getreal "\nPocket Depth: "))
(initget 1)
(setq PocketCB (getreal "\nPocket Cut Back: "))
(initget 1)
(setq GlueFL (getreal "\nGlue Flap Length: "))
(initget 1)
(setq GlueFW (getreal "\nGlue Flap Width: "))
(initget 1)
(setq GlueFCB (getreal "\nGlue Flap Cut Back: "))
;;=======calculate line endpoints=============
(setq hpi (/ pi 2))
(setq FlapJog (/ (- PocketD GlueFW GlueFCB) 2))
(setq Pt1 '(0.0 0.0);;LL corner of envelope
Pt2 (polar Pt1 hpi Length)
Pt3 (polar Pt2 0 Width)
Pt4 (polar Pt3 0 Width)
Pt5 (polar Pt4 (- hpi) Length)
Pt6 (polar Pt5 (- hpi) GlueFCB)
Pt7 (mapcar '+ Pt6 (list GlueFL (- Flapjog)))
Pt8 (polar Pt7 (- hpi) GlueFW)
Pt9 (polar Pt5 (- hpi) PocketD)
Pt10 (polar Pt9 pi (- Width PocketCB))
Pt11 (polar Pt10 hpi PocketD)
Pt12 (polar Pt1 0 Width)
);setq
(command "._layer" "_M" "CUT" "" "._color" "RED")
(command "._line" Pt1 Pt2 Pt3 Pt4 Pt6 Pt7 Pt8 Pt9 Pt10 Pt11 Pt1 "")
(command "._layer" "_M" "CREASE" "" "._color" "GREEN")
(command "._line" Pt3 Pt12 "" "._line" Pt11 Pt5 "" "._line" Pt6 Pt9 "")
;(command "._layer" "_S" "0" "" "._-color" "_bylayer")
(setvar "osmode" UserOS)
(princ)
);defun

thanks

leigh_elkins
6th Aug 2010, 10:47 am
This can be done in VBA. There isn't a straight forward conversion routine though, but I will see if I can dig out a bit of VBA I did a few years back which does a similar thing which will give you some pointers.

jimpcfd
10th Aug 2010, 01:04 pm
that would be great as i never done anything in VBA before.

cheers