Hole with thread many problems

Hole with thread many problems

Anonymous
Not applicable
779 Views
1 Reply
Message 1 of 2

Hole with thread many problems

Anonymous
Not applicable

hi I'm making trying to write a program that puts threaded holes in a preexisting object but i'm facing many problems when running this program if you can run it to see what I'm taking about. 

;HOLETHREAD.LSP
;Robin

;Define funtion comand
(defun c:holethread ()

;set props
  (setq scmde (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (setq sblip (getvar "blipmode"))
  (setvar "blipmode" 0)
  (setq sosmd (getvar "osmode"))
  (setvar "osmode" 0)
  (setq 3dosmd (getvar "3dosmode"))
  (setvar "3dosmode" 0)
  (setq dyucs (getvar "ucsdetect"))
  (setvar "ucsdetect" 0)
  (setq ccolor (getvar "cecolor"))

;start loop
  (setq A "y")
  (while (= A "y")

;get variables
    (setq e1 (entsel "\nselect the object"))
    (setvar "osmode" 1)
    (setq pt1 (getpoint "\nEnter location of new coordinate system: "))
    (setq pt2 (getpoint "\nEnter location of new x axis: "))
    (setq pt3 (getpoint "\nEnter location of new y axis: "))
    (command "ucs" 3 pt1 pt2 pt3)
    (setvar "osmode" 0)
    (setvar "blipmode" 1)
    (setq pt4 (getpoint "\nEnter location of center of the hole on the surface: "))
    (setvar "blipmode" 0)
    (setq D1 (getreal "\nInput Diameter of the hole: "))
    (setq L1 (getreal "\nInput depth of the hole (positive z direction): "))
    (setq c (getstring "\nColor of hole"))
    (command "color" c)
    (command "cylinder" pt4 D1 L1)
    (setq e2 (entlast))

;set up hole
    (if (>= L1 0)
      (progn
;- z direction
	(setq pt5 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) 0))
	(setq pt6 (list (car pt4) (- (car pt1) D1) (- (* D1 0.1))))
	(setq pt7 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) (- (* D1 0.2))))
	(setq pt8 (list (car pt4) (cadr pt4) (- (* D1 0.1))))
	(command "3DPOLY" pt5 pt6 pt7 "c")
	(setq e3 (entlast))
	(command "helix" pt8 (* 0.4 D1)(* 0.4 D1) "H" (* 0.41 D1) (+ (* 0.4 D1) L1))
	(setq e4 (entlast))
	(command "sweep" e3 "" "a" "n" e4 "")
	(setq e5 (entlast))
	(command "subtract" e2 "" e5 "")
	(setq e6 (entlast))
	)

      (progn
;+z direction
	(setq pt5 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) 0))
	(setq pt6 (list (car pt4) (- (car pt1) D1) (* D1 0.1)))
	(setq pt7 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) (* D1 0.1)))
	(setq pt8 (list (car pt4) (cadr pt4) (* D1 0.1)))
	(command "3DPOLY" pt5 pt6 pt7 "c")
	(setq e3 (entlast))
	(command "helix" pt8 (* 0.4 D1)(* 0.4 D1) "H" (* 0.41 D1) (+ (* 0.4 D1) L1))
	(setq e4 (entlast))
	(command "sweep" e3 "" "a" "n" e4 "")
	(setq e5 (entlast))
	(command "subtract" e2 "" e5 "")
	(setq e6 (entlast))
	))
    
;make hole
    (command "subtract" e1 "" e6 "")

;End Loop?
    (setq A (getstring "\nDo you want to create another hole (y or n)?"))
    )

; set back to starting state
  (command "ucs" "p")
  (command "vpoint" (list 1 -1 1))
  (command "vscurrent" 2)
  (setvar "cecolor" ccolor)
  (setvar "blipmode" sblip)
  (setvar "cmdecho" scmde)
  (setvar "osmode" snp)
  (setvar "3dosmode" 3dosmd)
  (setvar "ucsdetect" dyucs)
)
;End Program

 

0 Likes
780 Views
1 Reply
Reply (1)
Message 2 of 2

oscardosanjos
Enthusiast
Enthusiast

 Hi

Can you send an image to illustrate what do you want to create with this routine?

0 Likes