TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: andy_lee on August 01, 2015, 11:12:21 AM

Title: if no choice the surface ,Can't continue until chose the face
Post by: andy_lee on August 01, 2015, 11:12:21 AM
Dear all

We know (vl-cmdf "_.UCS" "_F") is returns T , and  (command "_.UCS" "_F") is returns nil

I want know
when I use  (command "_.UCS" "_F") or   (vl-cmdf "_.UCS" "_F"),   if  no choice the surface ,Can't continue  until  chose the face.
Is there any way to do it?
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: 77077 on August 02, 2015, 06:25:00 AM
I think no possible
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: mianbaoche on August 02, 2015, 07:29:13 AM
andy_lee Try!

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt()
  2.   (setq org (getvar "UCSORG"))
  3.   (vl-cmdf "_.UCS" "_F")
  4.   (while (null (equal 0 (distance (getvar "UCSORG" ) org) 1e-6))(vl-cmdf ""))
  5.  )

Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: andy_lee on August 03, 2015, 04:24:03 AM
andy_lee Try!

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt()
  2.   (setq org (getvar "UCSORG"))
  3.   (vl-cmdf "_.UCS" "_F")
  4.   (while (null (equal 0 (distance (getvar "UCSORG" ) org) 1e-6))(vl-cmdf ""))
  5.  )

Hi mianbaoche
The trouble is still exist .  Can use Dxf or vla to solve?
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: mianbaoche on August 03, 2015, 04:34:41 AM
You can tell what the results,continue  until  to do?

To speak clearly and easily understand

Can use Dxf or vla to solve?Not very understanding。
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: 77077 on August 03, 2015, 05:15:44 AM
I said that is not possible.
OP's describe is very clearly.  if this is  possible, Lee , roy ,ron  has given the answer.
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: andy_lee on August 03, 2015, 06:05:56 AM
Ok, Thanks guys.  I abandoned. :oops:
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: Kerry on August 04, 2015, 12:48:29 AM
andy_lee,
What is your goal ?

Do you require to set the UCS to a solid face without selecting the face ??

Do you have difficulty selecting/choosing the face ?

Are you unable to select the face for some reason ?

If you don't select the face, how do you imagine the UCS can be set ??

More explicit details of your requirements may help to find an answer.


//-----------------
added:
I have been watching this thread and noticed a lot of nasty behaviour which required deleted posts.
Please be a little nicer to each other ... we are ALL here to learn, not to play silly mean games.


Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: andy_lee on August 04, 2015, 01:50:56 AM
Hi Kerry
What happened?

sorry for my english .
Code - Auto/Visual Lisp: [Select]
  1.   (setq cmde (getvar 'cmdecho))
  2.   (setvar 'cmdecho 1)
  3.   (if e
  4.     (progn
  5.       (command "_.copybase" "_non" p e "" "")
  6.       (entdel e)
  7.       (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...")
  8.       (command "_.UCS" "_F")
  9.  

;;if  no choice the surface ,Can't continue

Code - Auto/Visual Lisp: [Select]
  1.       (while (< 0 (getvar 'cmdactive)) (command "\\"))
  2.       (setq p (getpoint "\nPick or specify top center point to place Trapezoid : "))
  3.       (command "_.pasteclip" "_non" p)
  4.       (command "_.rotate" (entlast) "" "_non" p "\\")
  5.     )
  6.   )
  7.   (command "_.UCS" "_P")
  8.   (*error* nil)
  9.  

The complete code from here:
Thanks marko.
http://www.theswamp.org/index.php?topic=49800.msg550233#msg550233
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: Kerry on August 04, 2015, 01:56:52 AM


So, you have resolved the problem ??
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: andy_lee on August 04, 2015, 01:58:47 AM


So, you have resolved the problem ??

No solution .
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: Kerry on August 04, 2015, 02:01:00 AM

Please read my post again.

What is your actual problem  ???
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: andy_lee on August 04, 2015, 02:04:29 AM

Please read my post again.

What is your actual problem  ???

 :cry: :cry: :cry:
http://www.theswamp.org/index.php?topic=49875.msg550678#msg550678

code...
I wrote explanatory notes here.
code...
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: Kerry on August 04, 2015, 02:09:00 AM

Please read my post again.

What is your actual problem  ???

 :cry: :cry: :cry:
http://www.theswamp.org/index.php?topic=49875.msg550678#msg550678

code...
I wrote explanatory notes here.
code...

What good is posting 'code' as an explanation for a problem if the code doesn't work.

I want you to read my post and answer the questions I asked.

Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: andy_lee on August 04, 2015, 02:48:41 AM

Please read my post again.

What is your actual problem  ???

 :cry: :cry: :cry:
http://www.theswamp.org/index.php?topic=49875.msg550678#msg550678

code...
I wrote explanatory notes here.
code...

What good is posting 'code' as an explanation for a problem if the code doesn't work.

I want you to read my post and answer the questions I asked.

Hi kerry
if use entsel function can like this :
(while (progn (null (setq e (entsel "\nPlease choose ."))))) ;; if no choose anything , can't continue or exit

as the same ,I need
 
when (command "_.UCS" "_F") , if no choose any face of 3d solid  ,can't run behind code

 (setq p (getpoint "\nPick or specify top center point to place Trapezoid : "))
 (command "_.pasteclip" "_non" p)
 (command "_.rotate" (entlast) "" "_non" p "\\")


Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: ribarm 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...
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: Kerry 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.
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: andy_lee 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 !   :-(
Title: Re: if no choice the surface ,Can't continue until chose the face
Post by: roy_043 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.