Author Topic: if no choice the surface ,Can't continue until chose the face  (Read 5682 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: if no choice the surface ,Can't continue until chose the face
« Reply #15 on: August 04, 2015, 03:10:15 AM »
Have you tried to modify my code as suggested by member like this :

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test ( / *error* dtr ac ab p sl a b c d e p ucsf cmde org )
  2.   ;;    Author : Tharwat Al Shoufi                      ;;
  3.   ;; Draw Trapezoid with angle 55 on the two sides      ;;
  4.   ;; -------------------------------------------------- ;;
  5.   (defun *error* ( msg )
  6.     (if cmde (setvar 'cmdecho cmde))
  7.     (if (not (eq (getvar 'worlducs) 1)) (command "_.UCS" "_P"))
  8.     (if ucsf (command "_.UCS" "_P"))
  9.     (if msg (prompt msg))
  10.     (princ)
  11.   )
  12.   (defun dtr (a) (* pi (/ a 180.0)))
  13.   (if (not *traplen*)
  14.     (setq *traplen* 10.0)
  15.   )
  16.   (if (not *traphgt*)
  17.     (setq *traphgt* 4.0)
  18.   )
  19.   (if (not (eq (getvar 'worlducs) 1))
  20.     (progn
  21.       (command "_.UCS" "_W")
  22.       (setq ucsf t)
  23.     )
  24.   )
  25.   (if (and (setq *traplen* (cond ((getdist (strcat "\n Specify Length of Trapezoid < " (rtos *traplen* 2 2) " > :")))
  26.                                  (*traplen*)
  27.                            )
  28.            )
  29.            (setq *traphgt* (cond ((getdist (strcat "\n Specify Height of Trapezoid < " (rtos *traphgt* 2 2) " > :")))
  30.                                  (*traphgt*)
  31.                            )
  32.            )
  33.            (setq ac (/ *traphgt* (sin (dtr 55.)))
  34.                  ab (* ac (cos (dtr 55.)))
  35.            )
  36.            (if (>= (setq sl (- *traplen* (+ ab ab))) 0.)
  37.              (setq p '(0.0 0.0 0.0))
  38.              (progn (alert "Length of Trapezoid is too small !!") nil)
  39.            )
  40.       )
  41.     (progn (setq a (polar p pi (/ sl 2.))
  42.                  b (polar a (dtr 235.) ac)
  43.                  c (polar b 0. *traplen*)
  44.                  d (polar c (dtr 125.) ac)
  45.                  e (entmakex
  46.                      (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1))
  47.                              (mapcar '(lambda (pt) (cons 10 (list (car pt) (cadr pt)))) (list a b c d))
  48.                      )
  49.                    )
  50.            )
  51.     )
  52.   )
  53.   (setq cmde (getvar 'cmdecho))
  54.   (setq org (getvar 'ucsorg))
  55.   (setvar 'cmdecho 1)
  56.   (if e
  57.     (progn
  58.       (command "_.copybase" "_non" p e "" "")
  59.       (entdel e)
  60.       (prompt "\nPick face of 3D solid (edge which is parallel to Trapezoid top edge), then adjust UCS further more (Xflip, Yflip, next face if wrong picked) and then press ENTER to accept...")
  61.       (command "_.UCS" "_F")
  62.       (while (< 0 (getvar 'cmdactive)) (command "\\"))
  63.       (while (equal 0.0 (distance (getvar 'ucsorg) org) 1e-6)
  64.         (command "_.UCS" "_F")
  65.         (while (< 0 (getvar 'cmdactive)) (command "\\"))
  66.       )
  67.       (setq p (getpoint "\nPick or specify top center point to place Trapezoid : "))
  68.       (command "_.pasteclip" "_non" p)
  69.       (command "_.rotate" (entlast) "" "_non" p "\\")
  70.     )
  71.   )
  72.   (command "_.UCS" "_P")
  73.   (*error* nil)
  74. )
  75.  

It should be working well all until you click on valid face of 3d solid...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: if no choice the surface ,Can't continue until chose the face
« Reply #16 on: August 04, 2015, 03:16:45 AM »
Why don't you want to pick a solid face to set the UCS.

Do you want to preset the UCS before you run the program ???


Do you know the best way to select the Face ??

The 3DSolid face data is not available to Lisp or VLisp so attempting to use entsel or entget is useless.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

andy_lee

  • Newt
  • Posts: 147
Re: if no choice the surface ,Can't continue until chose the face
« Reply #17 on: August 04, 2015, 03:51:05 AM »
Have you tried to modify my code as suggested by member like this :

It should be working well all until you click on valid face of 3d solid...

Thanks again ,marko   very cool .  ^-^

But I test maibaoche's code , It's not ok !   :-(
andy.
Best regards.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: if no choice the surface ,Can't continue until chose the face
« Reply #18 on: August 04, 2015, 05:39:36 AM »
Comparing the ucsorg to determine if the user has selected a face is problematic if the same face is selected twice.