New for AUTOLISP

Aug 03, 2005 10 Replies

I am writing a LISP routine for hob generation. I want to write a polar coordinate involving tangent function of an angle. DOes AutoLISP recongnize trigonomtric fnctions? If yes how to write them and how to write polar fnctions? ANy examples will be appreciated.



AutoLISP has built-in SIN, COS, and ATAN functions, which can be combined in the usual manner (i.e., TANx = SINx / COSx) to derive other functions as needed. ___

I am writing a LISP routine for hob generation. I want to write pola

Hi Dan,here sample if this script useful for yo

; ccs is stand for create coil sprin ; Design by Ade Suharna

I have tried the following program but somehow the repeat loop is not getting executed. Can anybody read this program and see if there is any error in this?

This program is for generating the gear involute profile using a straight flank hob. I draw the PCD, Hob profile and feed the roll angle and then I calculated the polar cooardinates where the hob should be inserted and rotated.

(defun c:HOB() (command "SNAP" "OFF") (setq cpg (list 0 0)) (setq ntg (getreal "\nEnter number of teeth on gear: ")) (setq dpg 1.000) (setq pdg (getreal "\nEnter generating pitch dia of gear: ")) (setq rolrad (/ pdg 2)) (setq rolangdeg (getreal "\nEnter Roll Angle of the tooth from OD to BD: ")) (setq numtgt (getint "\nEnter number of tangents: "))

(setq rolangrad (/ (* rolangdeg pi) 180.0))

(setq theta (/ rolangrad numtgt)) (setq pt2 (list -3 4)) (setq pt3 (list 3 7))

(setq rgt 1.0)

(while (

Seems to be a parenthesis problem somewhere. I think it is in this line:

Should it be (setq lay (getvar "clayer"))) perhaps?

It's correct with the two closing parentheses; why would you think otherwise? ___

I believe your problem is in trying to select the last insertion of HOB with a window. Try using (entlast) and don't forget to add an extra set of "" in your (command ...) statements to close out object selection. Here's a modified version of your code; I can't tell for sure if it's working as you expect, since I don't have a copy of your HOB block. Also, you don't need to use (progn ... ) with (while ...).

(defun c:HOB(/ cpg ntg dpg pdg rolrad rolangdeg numtgt theta pt2 pt3 rgt) (setvar "osmode" 0) (setq cpg (list 0 0)) (setq ntg (getint "\nEnter number of teeth on gear: ")) (setq dpg 1.0) (setq pdg (getdist "\nEnter generating pitch dia of gear: ")) (setq rolrad (/ pdg 2)) (setq rolangdeg (getreal "\nEnter Roll Angle of the tooth from OD to BD: ")) (setq numtgt (getint "\nEnter number of tangents: ")) (setq rolangrad (/ (* rolangdeg pi) 180.0)) (setq theta (/ rolangrad numtgt)) (setq rgt 1) (while (

Because it produces a parenthesis error message when I run it - but not with the additional one...

...that's all.

There may be a missing ")" somewhere in the code, but the error isn't in the line you cited. Parentheses are always balanced by function; every opening "(" requires exactly one closing ")" -- no more, no fewer. The line you cited has a total of two "(" balanced by two ")". ___

Yes indeed, so perhaps it's in the previous line where the parameters are defined. Seems to be two "(" but only one ")".

I'll give that a go.

Strange th> There may be a missing ")" somewhere in the code, but the error isn't

That's because that's the wrong place for the otherwise missing ")" ... The interpreter thinks the routine's done, but it isn't. Believe me, misplaced and/or improperly balanced parentheses can cause some very strange effects, and the errors aren't always immediately evident. LISP is a very structure-oriented language, and is very unforgiving in this respect. ___

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required