Author Topic: number rotate lisp error problem  (Read 1304 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 296
number rotate lisp error problem
« on: March 31, 2022, 11:54:06 PM »
hi
i made this code
that code is rotate code with  number
but  result is some error

what problem ?



Code - Auto/Visual Lisp: [Select]
  1. (defun Rtc ( / )
  2.     (setvar "cmdecho" 0)
  3.   (setq osm (getvar "osmode"))
  4.   (prompt "\nRotate Copy or Move")
  5.   (setq ss  (ssget)
  6.         bp  (getpoint "\nCenter point: ")
  7.         tmp 0.0
  8.   )
  9.   (setq angPER (getint (strcat "\n number <" (rtos tmp) ">")))
  10.         (setq ang ( / 360  angPER))
  11.        
  12.                 (repeat angPER
  13.    
  14.        
  15.    
  16.    
  17.         (command "rotate" ss "" bp ang)
  18.        
  19.      
  20.                         )
  21.   )


EDIT (John): Added code tags.
« Last Edit: April 01, 2022, 05:56:45 AM by JohnK »

MatGrebe

  • Mosquito
  • Posts: 16
Re: number rotate lisp error problem
« Reply #1 on: April 01, 2022, 03:01:28 AM »
What error do you get ? If you just press Enter (and not type a value) angper will be NIL and then your calculation doesn't work.
Mathias 

dussla

  • Bull Frog
  • Posts: 296
Re: number rotate lisp error problem
« Reply #2 on: April 01, 2022, 05:35:59 AM »
What error do you get ? If you just press Enter (and not type a value) angper will be NIL and then your calculation doesn't work.
Mathias

Can you see the dwg file?
If you rotate
Does not rotate to the correct angle

For example, if you enter 7
the result is weird

ribarm

  • Gator
  • Posts: 3278
  • Marko Ribar, architect
Re: number rotate lisp error problem
« Reply #3 on: April 01, 2022, 05:58:23 AM »
What error do you get ? If you just press Enter (and not type a value) angper will be NIL and then your calculation doesn't work.
Mathias

Can you see the dwg file?
If you rotate
Does not rotate to the correct angle

For example, if you enter 7
the result is weird

Cnsider using reals instead if integers for calculation!!!
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

dussla

  • Bull Frog
  • Posts: 296
Re: number rotate lisp error problem
« Reply #4 on: April 01, 2022, 10:20:45 AM »
What error do you get ? If you just press Enter (and not type a value) angper will be NIL and then your calculation doesn't work.
Mathias

Can you see the dwg file?
If you rotate
Does not rotate to the correct angle

For example, if you enter 7
the result is weird

Cnsider using reals instead if integers for calculation!!!


Really thank you
Work good

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: number rotate lisp error problem
« Reply #5 on: April 04, 2022, 06:00:13 PM »
A few things to consider:
  • Store the value of all system variables before making any changes, and reset them to their original values, rather than assuming that CMDECHO should be set to 1
  • Consider the effect of any active Object Snap modes when supplying the base point to the ROTATE command - you can use the "_non" modifier to ignore all active snaps prior to the point input
  • Consider the possibility that the user may not supply a valid selection, point, or number and use a conditional statement (if/cond) to branch accordingly
  • The value of the 'default' variable tmp will never be assigned to the variable angPer even if the user presses ENTER
  • Consider that the division of two integers will always yield an integer in AutoLISP
  • Use a final (princ) or (prin1) expression as the last expression in the function definition to return a null symbol (i.e. a 'clean' output) to the command line, rather than the value returned by the repeat expression
  • Declare the variables that are local to your function to avoid symbols clashing in the document namespace
« Last Edit: April 04, 2022, 06:09:17 PM by Lee Mac »