Jump to content

Recommended Posts

Cunha

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

Share this post


Link to post
Share on other sites
Lee Mac

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

Share this post


Link to post
Share on other sites
SLW210

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

Share this post


Link to post
Share on other sites
Cunha

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

Share this post


Link to post
Share on other sites
Cunha

Thanks SLW210 for reminding me.

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

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...