Jump to content

Recommended Posts

Posted (edited)

Hi, I'm trying to create a routine to draw trapezoidal threads in Adcad2000. I don't understand why it does not work.

Can someone help me? I really appreciate, hugs.

 

 

 

Code:

 

;Program that subtracts a 'cut entity' of a cylinder, shifts it along

;and turns it to make new cut, "N" times each "M" turns.

;Requirements: horizontal cylinder axle and load of "geom3d.arx" (Acad2000).

(DEFUN C:LATHE (/) (Setq AUN (getvar "aunits")) (setvar "aunits" 0)

(progn

(setq Cylinder (entsel "\nClik the Cylinder to 'lathe': "))

(setq PtoA (GETPOINT "\nClick at START (center) of Cylinder: "))

(setq PtoB (GETPOINT "\nClick at END of Cylinder (center): "))

(setq CutEntity (entsel "\nSelect a 'CUT-ENTITY': "))

(princ "\nTotal Number of TURNS (spiral): ") (setq NTv (getint)) (setq Nv 1)

(princ "\nHow many CUTS by TURN (resolution): ") (setq NCv (getint))

(setq Nc 1) (setq Step (/ (distance PtoA PtoB) (* NCv NTv)))

(setq AngularStep (/ 360 NCv)) (setq PtoC (polar PtoA (angle PtoA PtoB) Step))

(while (>= NTv Nv)

(while (>= NCv Nc)

(command "copy" CutEntity "" "0,0,0" "0,0,0")

(command "subtract" Cylinder "" CutEntity "")

(command "move" Cylinder PtoC PtoA)

(command "rotate3d" Cylinder PtoA PtoB AngularStep)

(setq Nc (+ Nc 1))

)

(setq Nv (+ Nv 1)) (setq Nc 1)

)

) (setvar "aunits" AUN)

)

Edited by Cunha
Posted

After a cursory glance over your code, try setting OSMODE to 0 before your while loop, resetting it afterwards (as you have with AUNITS).

Posted (edited)

Thanks Lee. I have made the alteration and some changes; beyond the control of Osmode, now I'm referencing the cylinder just by entity name (because it remains even after move, rotate and cut) and I kept control of repetitions without using counters (an old mania).

Now it's stopping for exceeding 4 level of nesting and crashing run. Can't understand.

;Program that subtracts a 'cut entity' of a cylinder, shifts it along
;and turns it to make new cut, "N" times each "M" turns.
;Requirements: horizontal cylinder axle and load of "geom3d.arx" (Acad2000).
; --- July/14/2016 --- Attention please: This program IS NOT FUNCTIONAL yet.
(DEFUN C:LATHE (/)
(Setq AUN (getvar "aunits")) (setvar "aunits" 0)
(Setq OSM (getvar "osmode")) (setvar "osmode" 0)
 (progn
   (setq Cyl (entsel "\nClik the Cylinder to 'lathe': "))
   (setq Cylinder (car Cyl))
   (setq PtoA (GETPOINT "\nClick at START (center) of Cylinder: "))
   (setq PtoB (GETPOINT "\nClick at END of Cylinder (center): "))
   (setq CutEntity (entsel "\nSelect a 'CUT-ENTITY': "))
   (princ "\nTotal Number of TURNS (spiral): ") (setq NTv (getint))
   (princ "\nHow many CUTS by TURN (resolution): ") (setq NCv (getint))
   (setq Step (/ (distance PtoA PtoB) (* NCv NTv)))
   (setq AngularStep (/ 360 NCv))
   (setq PtoC (polar PtoA (angle PtoA PtoB) Step))
   (repeat NTv
     (repeat NCv
       (command "copy" CutEntity "" "0,0,0" "0,0,0")
       (command "subtract" Cylinder "" CutEntity "")
       (command "move" Cylinder PtoC PtoA)
       (command "rotate3d" Cylinder PtoA PtoB AngularStep)
     )
   )
 ) (setvar "aunits" AUN) (setvar "osmode" OSM)
)

Edited by Cunha
Posted (edited)

Thanks SLW210 for reminding me.

Edited by Cunha
Sorry, I'm translating from Portuguese and it sounded bad.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...