Author Topic: Rotate Reference  (Read 1007 times)

0 Members and 1 Guest are viewing this topic.

DanB

  • Bull Frog
  • Posts: 367
Rotate Reference
« on: February 18, 2022, 09:43:31 AM »
I've tried various osnap presets and I can't seem to prevent the command from "jumping" to an inaccurate location. I get very mixed results with the basepoint and/or the reference points. I've attached a GIF showing the basepoint "jumping" to a unwanted location. Any suggestions?

Ideally I would want the basepoint selection to be CENTER osnap, then reference points are both ENDPOINTS, always defaulting back to my original OSNAP settings.

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Rotate Reference
« Reply #1 on: February 18, 2022, 09:59:07 AM »
This mod. should solve your task...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ror ( / *error* cmde oldos ss1 pnt1 pnt2 )
  2.  
  3.   (defun *error* ( msg )
  4.     (if oldos
  5.       (setvar "osmode" oldos)
  6.     )
  7.     (if cmde
  8.       (setvar "cmdecho" cmde)
  9.     )
  10.     (if (not (member (strcase msg T)
  11.          '("quit / exit abort" "function cancelled" "console break")
  12.               )
  13.         )
  14.       (princ "\nError: " msg)
  15.     )
  16.     (princ)
  17.   )
  18.  
  19.   (setq cmde (getvar "cmdecho"))
  20.   (setvar "cmdecho" 0)
  21.   (setq oldos (getvar "osmode"))
  22.   (setvar "osmode" 0)
  23.   (prompt "\nSelect objects on unlocked layer(s) that are to be rotated with reference base angle option...")
  24.   (setq ss1 (ssget "_:L"))
  25.   (setvar "osmode" 4)
  26.   (initget 1)
  27.   (setq pnt1 (getpoint "\nPick/Specify Base Point : "))
  28.   (setvar "osmode" 1)
  29.   (initget 1)
  30.   (setq pnt2 (getpoint pnt1 "\nPick/Specify First Reference Point : "))
  31.   (prompt "\nPick/Specify Second Reference Point : ")
  32.   (command "_.ROTATE" ss1 "" "_non" pnt1 "_R" "_non" pnt1 "_non" pnt2 "\\")
  33.   (*error* nil)
  34. )
  35.  
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

DanB

  • Bull Frog
  • Posts: 367
Re: Rotate Reference
« Reply #2 on: February 18, 2022, 11:34:35 AM »
My initial testing looks like this is working well, thank you.

If you have time can you elaborate on your modifications?

1. INIGET - simply appears to prevent NIL input, don't think this addition was in relation to my OSNAP issue, likely just cleaner coding?

2. I do not understand the addition of "_non" in this line:   (command "_.ROTATE" ss1 "" "_non" pnt1 "_R" "_non" pnt1 "_non" pnt2 "\\")


Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Rotate Reference
« Reply #3 on: February 20, 2022, 06:56:34 AM »
2. I do not understand the addition of "_non" in this line:   (command "_.ROTATE" ss1 "" "_non" pnt1 "_R" "_non" pnt1 "_non" pnt2 "\\")

My post here should hopefully help to answer this, and also provide you with some alternative methods to achieve the same thing.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Rotate Reference
« Reply #4 on: February 20, 2022, 07:42:44 AM »
Where the use of initget is concerned, whilst this prevents the user from dismissing the prompt (thereby forcing the user to either supply a valid input or cancel the program by pressing Esc), I personally prefer to allow the user to exit the program cleanly by dismissing the prompt, and use a conditional statement (if/cond) to branch the evaluation of the program accordingly, based on the input provided, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:ror ( / pt1 pt2 sel )
  2.     (if (and (setq sel (ssget "_:L"))
  3.              (setq pt1 (getpoint "\nSpecify base point: "))
  4.              (setq pt2 (getpoint pt1 "\nSpecify 1st reference point: "))
  5.         )
  6.         (command "_.rotate" sel "" "_non" pt1 "_r" "_non" pt1 "_non" pt2 "\\")
  7.     )
  8.     (princ)
  9. )

DanB

  • Bull Frog
  • Posts: 367
Re: Rotate Reference
« Reply #5 on: February 21, 2022, 08:46:54 AM »
Thank you for the follow up, will dig into this more, already have another situation I think I can apply this to.