Cunha Posted July 13, 2016 Posted July 13, 2016 (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 July 17, 2016 by Cunha Quote
Lee Mac Posted July 13, 2016 Posted July 13, 2016 After a cursory glance over your code, try setting OSMODE to 0 before your while loop, resetting it afterwards (as you have with AUNITS). Quote
SLW210 Posted July 13, 2016 Posted July 13, 2016 Please read the Code Posting Guidelines and edit your post to include the Code in Code Tags. [NOPARSE] Your Code Here [/NOPARSE] = Your Code Here Quote
Cunha Posted July 13, 2016 Author Posted July 13, 2016 (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 July 14, 2016 by Cunha Quote
Cunha Posted July 13, 2016 Author Posted July 13, 2016 (edited) Thanks SLW210 for reminding me. Edited July 13, 2016 by Cunha Sorry, I'm translating from Portuguese and it sounded bad. Quote
Recommended Posts
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.