Author Topic: - = { Challenge } = - transform UCS along with entities  (Read 1799 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3282
  • Marko Ribar, architect
- = { Challenge } = - transform UCS along with entities
« on: June 18, 2015, 05:29:32 PM »
I have a task to perform with commands for modify objects, only now I wish it's applicable to both entities along with UCS entity... I know it's doable, but it would be nice to make it simple like typing original command at command prompt with suffix or prefix for UCS (for ex. rotate3d-U)... It would be nice if all modify commands could be used with calling correct cmdname with just single master routine (code) applicable for all commands for modify... I am little lazy now, but it's just a thought and I don't know if it would be much useful, but if it was possible to make UCS follow VIEW change than this is no big difference only more options to consider (rotate3d, mirror3d, align, rotate, mirror, scale, stretch, move, copy ...) Or I am just silly, no one would need this operational... Maybe to create command reactor that will trigger UCS modification but with the same parameters used while command is processed...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3282
  • Marko Ribar, architect
Re: - = { Challenge } = - transform UCS along with entities
« Reply #1 on: June 19, 2015, 05:12:52 AM »
1. Of course, with mirror or mirror3d commands, you should think if you should invert Z axis of UCS and mark that UCS (-1), so that when used (trans) function correct result should be obtained (trans function should be unchanged) only when computing point to be transformed that (-1) sign of UCS should automatically multiply Z coordinate of point with -1... Maybe for better viewing (blue) color from Z arrow of UCS to be changed to (yellow)...

2. Or this all is complication UCS axis shouldn't be inverted at all while mirror or mirror3d, but then it should point at opposite direction from before transformation so that 3 finger rule wouldn't change (after mirror or mirror3d z coordinate of all transformed entities would become Z original * (-1)...

As my first comment involve more complex change (maybe in future CAD development), I suggest that for start UCS transformation for those commands be like described in my second comment...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3282
  • Marko Ribar, architect
Re: - = { Challenge } = - transform UCS along with entities
« Reply #2 on: June 19, 2015, 09:43:40 AM »
Here is my first attempt on the subject...

It's very simple, so don't laugh...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:modents+ucs ( / *error* *adoc* cmde cmd ss xli yli zli o x y z )
  2.  
  3.  
  4.   (defun *error* ( msg )
  5.     (if cmde (setvar 'cmdecho cmde))
  6.     (if (and xli (entget xli)) (entdel xli))
  7.     (if (and yli (entget yli)) (entdel yli))
  8.     (if (and zli (entget zli)) (entdel zli))
  9.     (if msg (prompt msg))
  10.     (vla-endundomark *adoc*)
  11.     (command "_.UNDO" "")
  12.     (princ)
  13.   )
  14.  
  15.   (vla-startundomark *adoc*)
  16.   (setq cmde (getvar 'cmdecho))
  17.   (setvar 'cmdecho 1)
  18.   (initget 1 "MOVE ALIGN ROTATE MIRROR SCALE ROTATE3D 3DMIRROR 3DROTATE STRETCH")
  19.   (setq cmd (getkword "\nENTER COMMAND [MOve/ALign/ROtate/MIrror/SCale/ROTATE3D/3DMIrror/3DROtate/STretch] : "))
  20.   (prompt "\nSelect object(s) - (ENTER : APPLY COMMAND ONLY TO UCS)...")
  21.   (setq ss (ssget "_:L"))
  22.   (if (null ss) (setq ss (ssadd)))
  23.   (if (eq cmd "3DMIRROR") (setq cmd "MIRROR3D"))
  24.   (setq xli (entmakex (list '(0 . "LINE") '(62 . 1) (cons 10 (trans '(0.0 0.0 0.0) 1 0)) (cons 11 (trans '(1.0 0.0 0.0) 1 0)))))
  25.   (setq yli (entmakex (list '(0 . "LINE") '(62 . 3) (cons 10 (trans '(0.0 0.0 0.0) 1 0)) (cons 11 (trans '(0.0 1.0 0.0) 1 0)))))
  26.   (setq zli (entmakex (list '(0 . "LINE") '(62 . 5) (cons 10 (trans '(0.0 0.0 0.0) 1 0)) (cons 11 (trans '(0.0 0.0 1.0) 1 0)))))
  27.   (ssadd xli ss)
  28.   (ssadd yli ss)
  29.   (ssadd zli ss)
  30.   (cond
  31.     ( (eq (strcase cmd) "MIRROR")
  32.       (command cmd ss "" "\\" "\\" "Y")
  33.     )
  34.     ( (eq (strcase cmd) "MIRROR3D")
  35.       (alert "When asked : Delete source objects? - answer : (Y)es and press ENTER twice...")
  36.       (command cmd ss "")
  37.       (while (> (getvar 'cmdactive) 0) (command "\\"))
  38.     )
  39.     ( (eq (strcase cmd) "ALIGN")
  40.       (alert "When align command completes and marker icon was aligned press ENTER to change UCS to marker...")
  41.       (command cmd ss "")
  42.       (while (> (getvar 'cmdactive) 0) (command "\\"))
  43.     )
  44.     ( t
  45.       (command cmd ss "")
  46.       (while (> (getvar 'cmdactive) 0) (command "\\"))
  47.     )
  48.   )
  49.   (setq o (trans (cdr (assoc 10 (entget xli))) 0 1))
  50.   (setq x (trans (cdr (assoc 11 (entget xli))) 0 1))
  51.   (setq y (trans (cdr (assoc 11 (entget yli))) 0 1))
  52.   (setq z (trans (cdr (assoc 11 (entget zli))) 0 1))
  53.   (entdel xli)
  54.   (entdel yli)
  55.   (entdel zli)
  56.   (command "_.UCS" "_3P" "_non" o "_non" x "_non" y)
  57.   (princ)
  58. )
  59.  
  60. (defun c:meu nil (c:modents+ucs))
  61.  

M.R.
« Last Edit: June 20, 2015, 07:48:17 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube