Author Topic: How to get point inner rectangular  (Read 3443 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
How to get point inner rectangular
« on: November 07, 2006, 01:16:22 AM »
Hi Alls,
I got problem to get point inner rectangular,that point have Z value,if I use my code, variable "ss" would get result nil,any one have idea?,thanks
Code: [Select]
(defun c:test ()
  (setq p1 '(0.0 0.0 0.0))
  (setq p2 '(1.0 0.5 0.0))
  (setq ss (ssget "_wp" (list p1 p2)))
  (princ)
  )

Serge J. Gianolla

  • Guest
Re: How to get point inner rectangular
« Reply #1 on: November 07, 2006, 02:56:17 AM »
Have not looked at your ZIP file. I do not understand when you say points have a Z value, yet in your example Z=0!

If point p2 is opp. corner of rectangle, you cannot use WP to select! And if you are after WP then you need more points in your list. You cannot have a polygon with one gon/edge/side.

Adesu

  • Guest
Re: How to get point inner rectangular
« Reply #2 on: November 07, 2006, 03:41:06 AM »
Hi Serge,
Very sorry last post without zip file,it file have memory more than 10 kb,I'm still to attempting post here with others way.
I hope you patient to wait my zip post here.

Have not looked at your ZIP file. I do not understand when you say points have a Z value, yet in your example Z=0!

If point p2 is opp. corner of rectangle, you cannot use WP to select! And if you are after WP then you need more points in your list. You cannot have a polygon with one gon/edge/side.

CarlB

  • Guest
Re: How to get point inner rectangular
« Reply #3 on: November 07, 2006, 03:45:03 AM »
I think Serge has it.  You probably should use "_W" or "_C" instead of "_WP".

Adesu

  • Guest
Re: How to get point inner rectangular
« Reply #4 on: November 07, 2006, 04:14:28 AM »
Hi CarlB,
Here my code to erase object point inner rectangular
Code: [Select]
(defun cl3 (lst / b)                          ; by Adesu
  (setq b (member (cadddr lst) lst))
  (list (list (car lst)(cadr lst)(caddr lst))
(list (car b)(cadr b)(caddr b))
(member (cadddr b) b))
  )

(defun c:test (/ ang cnt ep p1 p2 p3 p4 sp ss sse ssl ssn ssx)
  (setq ss (car (entsel "\nSelect a line"))) ; select 3dpoly line
  (setq vevo (vlax-ename->vla-object ss))
  (setq cor (vlax-get vevo 'Coordinates))  ; (9.14339 7.64805 1.5 24.0489 22.0432 2.5)
  (setq len (length cor))                  ; 6
  (setq div (/ len 3))                     ; 2
  (if
    (= div 2)
    (progn
      (setq lst (cl3 cor))                  ; ((9.14339 7.64805 1.5) (24.0489 22.0432 2.5) nil)
      (setq sp (nth 0 lst))                 ; (9.14339 7.64805 1.5)
      (setq ep (nth 1 lst))                 ; (24.0489 22.0432 2.5)
      (setq ang (angle sp ep))              ; 0.767982
      (setq p1 (polar sp (+ (* pi 0.5) ang) 2.5))
      (setq p2 (polar sp (+ (* pi 1.5) ang) 2.5))
      (setq p3 (polar ep (+ (* pi 1.5) ang) 2.5))
      (setq p4 (polar ep (+ (* pi 0.5) ang) 2.5))
     
      (setq ssx (ssget "_w"  p1 p3 '((0 . "point"))))
     
      (setq ssl (sslength ssx))
      (setq cnt 0)
      (repeat
ssl
(setq ssn (ssname ssx cnt))
(command "_erase" ssn "")
(setq cnt (1+ cnt))
)                            ; repeat
      )                              ; progn
    )                                ; if
  (princ)
  )                              ; defun



I think Serge has it.  You probably should use "_W" or "_C" instead of "_WP".

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to get point inner rectangular
« Reply #5 on: November 07, 2006, 07:41:36 AM »
Maybe this?
Code: [Select]
;;  get pline vrtex list
(defun get_pline_cor (elst)
  (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) elst))
)

(defun c:test (/ ang cnt ep p1 p2 p3 p4 sp ent sse ssl ssn ssx)
  (prompt "\nSelect a closed LWpolyline")
  (if (setq ss (ssget ":E:S" '((0 . "LWPOLYLINE")(-4 . "&")(70 . 1))))
    (progn
      (setq ent (ssname ss 0))
      (setq cor (get_pline_cor (entget ent)))
      (setq cor (append cor (list(car cor))))
      (setq ssx (ssget "_cp" cor '((0 . "point"))))
      (setq ssl (sslength ssx))
      (command "_erase" ssx "")
    ) ; progn
  )  ; if
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Adesu

  • Guest
Re: How to get point inner rectangular
« Reply #6 on: November 07, 2006, 07:00:18 PM »
Hi CAB,
Your code got trouble,look this below

_$  (setq ss (ssget ":E:S" '((0 . "LWPOLYLINE")(-4 . "&")(70 . 1))))
nil
_$ (setq ent (ssname ss 0))
; error: bad argument type: lselsetp nil
_$

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get point inner rectangular
« Reply #7 on: November 07, 2006, 07:42:30 PM »
No, his code does not have trouble :-)

You do !

You missed the (if .... statement
If the ss is not nil then do everything in the progn ...

you try to (setq ent .. when ss is obviously nil
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to get point inner rectangular
« Reply #8 on: November 07, 2006, 07:54:48 PM »
 :wink:
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Adesu

  • Guest
Re: How to get point inner rectangular
« Reply #9 on: November 08, 2006, 12:42:45 AM »
Hi Kerry and CAB,
I'm still analysising my code to solve that problem,look at this.
the problem still in variable "ssx"

_$ (defun get_pline_cor (elst)
  (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) elst))
)
GET_PLINE_COR
_$ (prompt "\nSelect a closed LWpolyline")
  (if (setq ss (ssget ":E:S" '((0 . "LWPOLYLINE")(-4 . "&")(70 . 1))))
    (progn
      (setq ent (ssname ss 0))
      (setq cor (get_pline_cor (entget ent)))
      (setq cor (append cor (list(car cor))))
      (setq ssx (ssget "_cp" cor '((0 . "point"))))
      (setq ssl (sslength ssx))
      (command "_erase" ssx "")
    ) ; progn
  )  ; if
nil
; error: bad argument type: lselsetp nil
_$
_$ (setq ss (ssget ":E:S" '((0 . "LWPOLYLINE")(-4 . "&")(70 . 1))))
<Selection set: 91>
_$ (setq ent (ssname ss 0))
      (setq cor (get_pline_cor (entget ent)))
      (setq cor (append cor (list(car cor))))
      (setq ssx (ssget "_cp" cor '((0 . "point"))))
      (setq ssl (sslength ssx))
      (command "_erase" ssx "")
<Entity name: 6b062000>
((-66.7092 46.6143) (72.8231 46.6143) (72.8231 -9.22905) (-66.7092 -9.22905))
((-66.7092 46.6143) (72.8231 46.6143) (72.8231 -9.22905) (-66.7092 -9.22905) (-66.7092 46.6143))
nil
; error: bad argument type: lselsetp nil
_$ (setq ssx (ssget "_cp" cor '((0 . "point"))))
nil
_$

Adesu

  • Guest
Re: How to get point inner rectangular
« Reply #10 on: November 08, 2006, 12:56:11 AM »
Hi CAB,
That right your code is perfect,I just tested again.
thanks a lot for your help.