Monday, August 9, 2010

Ouch!.....Again!

I'm not having a good run lately. Things seem to be going wrong on a daily basis at the moment after a dream run of 2 years with no problems.

The latest drama is a lisp routine, which while seeming to do the job, was not really.

The routine in question is a round flange drawing one. The problem was that while I keyed in a pitch circle diameter of 295mm, it took it upon itself to draw one at 297.82mm or so....Nasty, because the flange looked ok.

The lesson learned? Make sure any routine that draws anything sets the osmode (ie the running snap value) to ZERO. ie to achieve this , use the following code:

(setvar "osmode" oldsnapmode);this is so that you can reset at the end
(setvar "osmode" 0)

Here is the routine, if you like such things, cut and paste into notepad,
call it flan3d.lsp and load it by dragging it from explorer into your autocad drawing.

To run, type flan3d at the prompt.

;Program written by Bill Le Couteur
;Auckland NZ
;Rev 0 date 16/6/00
;This program draws a flange in 3d

(defun c:flan3d()
(setvar "CMDECHO" 0)
(setq oldsnapmode (getvar "osmode"))
(setvar "osmode" 0)
(setq flangeod(getreal "\nEnter the outside diameter: "))
(setq flthick(getreal "\nEnter the Thickness: "))
(setq flangeid(getreal "\nEnter the Internal Diameter : "))
(setq boltholedia(getreal "\nEnter the Bolt Hole Diameter: "))
(setq boltpcd(getreal "\nEnter the PCD: "))
(setq no_holes (getint "\Enter the number of holes: "))
(setq boltpcr (/ boltpcd 2))
(setq the_point (getpoint "\nPick the point to draw it: "))
(command "cylinder" the_point "d" flangeod flthick)
(command "cylinder" the_point "d" flangeid flthick)
(command "cylinder" the_point "d" boltholedia flthick)
(command "move" "l" "" "0,0" (list boltpcr 0))
(command "array" "l" "" "p" the_point no_holes "" "" )
(setvar "osmode" oldsnapmode)
(setvar "CMDECHO" 1)
(princ)
)

No comments: