Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Please Help Something wrong: How can make better?.

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
jinkinglee
385 Views, 5 Replies

Please Help Something wrong: How can make better?.

(defun dtr (deg /) (* (/ deg 180.0) pi))
(setq piu (/ pi 2.0))
(setq pid (* pi 1.5))
(defun cm_inch (cm /)
  (/ cm 2.54)
)
(setq Text_Size 0.5)
(setvar "cmdecho" 1)

(DEFUN c:learn ()
  (setq p1 (getpoint "ENTER ORIGIN POINT"))
  (if (= P1 nil)
    (setq P1 '(30 0))
  )
  (setq Height 80.0)
  (SETQ f_0 (POLAR P1 (dtr 0.0) 10.0))
  (SETQ f_0 (POLAR f_0 PIU (/ Height 8.0)))
  (SETQ f_1 (POLAR f_0 PID (/ Height 8.0)))
  (SETQ f_2 (POLAR f_1 PID (/ Height 8.0)))
  (SETQ f_3 (POLAR f_2 PID (/ Height 8.0)))
  (SETQ f_4 (POLAR f_3 PID (/ Height 8.0)))
  (SETQ f_5 (POLAR f_4 PID (/ Height 8.0)))
  (SETQ f_6 (POLAR f_5 PID (/ Height 8.0)))
  (SETQ f_7 (POLAR f_6 PID (/ Height 8.0)))
  (SETQ f_8 (POLAR f_7 PID (/ Height 8.0)))
  (COMMAND "TEXT" "J" "_BL" f_0 0.5 0 " f_0")
  (COMMAND "TEXT" "J" "_BL" f_1 0.5 0 " f_1")
  (COMMAND "TEXT" "J" "_BL" f_2 0.5 0 " f_2")
  (COMMAND "TEXT" "J" "_BL" f_3 0.5 0 " f_3")
  (COMMAND "TEXT" "J" "_BL" f_4 0.5 0 " f_4")
  (COMMAND "TEXT" "J" "_BL" f_5 0.5 0 " f_5")
  (COMMAND "TEXT" "J" "_BL" f_6 0.5 0 " f_6")
  (COMMAND "TEXT" "J" "_BL" f_7 0.5 0 " f_7")
  (COMMAND "TEXT" "J" "_BL" f_8 0.5 0 " f_8")
  (COMMAND "LINE" f_0 f_8 "")
  (COMMAND "LINE" f_0 "@-36,0.0" "")
  (COMMAND "LINE" f_1 "@-36,0.0" "")
  (COMMAND "LINE" f_2 "@-36,0.0" "")
  (COMMAND "LINE" f_3 "@-36,0.0" "")
  (COMMAND "LINE" f_4 "@-36,0.0" "")
  (COMMAND "LINE" f_5 "@-36,0.0" "")
  (COMMAND "LINE" f_6 "@-36,0.0" "")
  (COMMAND "LINE" f_7 "@-36,0.0" "")
  (COMMAND "LINE" f_8 "@-36,0.0" "")
  (command "zoom" "ALL")
)

 

5 REPLIES 5
Message 2 of 6
Kent1Cooper
in reply to: jinkinglee

Saying "something wrong" is not enough information.  What is wrong?  Does it not do anything?  Does it do something different from what you expect?  In what way should it be better?  Etc.

 

In the meantime, a few of things I notice:

 

The (dtr) function is not needed if you use it only for (dtr 0.0) -- you don't need to bother with (dtr) but can just use 0.0 directly.

 

The (cm_inch) function does not appear to be used at all.

 

I would think you would want to turn command echoing off rather than on, i.e. (setvar "cmdecho" 0).

Kent Cooper, AIA
Message 3 of 6
hgasty1001
in reply to: jinkinglee

Hi,

 

Kent is right, "something wrong" is not enough information. Just a guess:Try setting OSMODE to 0 *Before* anything (setvar "osmode" 0).

 

Gaston Nunez

Message 4 of 6
doni49
in reply to: Kent1Cooper


@Kent1Cooper wrote:

Saying "something wrong" is not enough information.  What is wrong?  Does it not do anything?  Does it do something different from what you expect?  In what way should it be better?  Etc.

 

In the meantime, a few of things I notice:

 

The (dtr) function is not needed if you use it only for (dtr 0.0) -- you don't need to bother with (dtr) but can just use 0.0 directly.

 

The (cm_inch) function does not appear to be used at all.

 

I would think you would want to turn command echoing off rather than on, i.e. (setvar "cmdecho" 0).


In addition, you're turning of cmdecho OUTSIDE of the lisp routine (that line of code will only run when you initially load the file).  Turn it OFF at the beginning of the routine and then back on at the end of the routine.



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 5 of 6
doni49
in reply to: doni49

I saw one other thing to note.

 

(SETQ f_0 (POLAR P1 (dtr 0.0) 10.0))
  (SETQ f_0 (POLAR f_0 PIU (/ Height 8.0))) ; <-- all the other lines spec a PID variable.  But this one is PIU.
  (SETQ f_1 (POLAR f_0 PID (/ Height 8.0)))
  (SETQ f_2 (POLAR f_1 PID (/ Height 8.0)))
  (SETQ f_3 (POLAR f_2 PID (/ Height 8.0)))
  (SETQ f_4 (POLAR f_3 PID (/ Height 8.0)))
  (SETQ f_5 (POLAR f_4 PID (/ Height 8.0)))
  (SETQ f_6 (POLAR f_5 PID (/ Height 8.0)))
  (SETQ f_7 (POLAR f_6 PID (/ Height 8.0)))
  (SETQ f_8 (POLAR f_7 PID (/ Height 8.0)))

 

 



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 6 of 6
smaher12
in reply to: jinkinglee

If you want a short version...

 

(defun c:test (/ p1 p2 p3 cnt p4)
  (setvar 'cmdecho 0)
  (setq p1 (getpoint "\nSpecify origin point" )
	p2 (polar p1 (/ pi 2) 64)
  ); setq
  (command "_.line" "_none" p2 "_none" p1 "_none" (polar p1 pi 36) ""
	   "_.text" "bl" "_none" p1 0.5 0 " f_0"
	   )
  (setq p3 p1)
  (setq cnt 1)
  (while (< 7 (distance p3 p2))
    (setq p4 (polar p3 (/ pi 2) 8))
    (command "_.line" "_none" p4 "_none" (polar p4 pi 36) ""
	     "_.text" "bl" "_none" p4 0.5 0  (strcat " f_" (rtos cnt 2 0))
    )
    (setq p3 p4)
    (setq cnt (1+ cnt))
  ); while
 (princ)
)

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost