Author Topic: capturing point features  (Read 2290 times)

0 Members and 1 Guest are viewing this topic.

viva

  • Guest
capturing point features
« on: August 15, 2006, 04:13:55 AM »
hello everybody,
          i had developed one lisp program for capturing the point features at the starting and ending point point of the polyline. here point feature and polyline is in different layer.it is working fine in some drawing and it is not working properly in many drawing. i had posted the code for ur verification. can anyone help me solve the problem.

Code: [Select]
(defun c:chk_ski()
  (command "zoom" "e")
(setq echo (getvar "cmdecho")
osmode (getvar "osmode"))
  (setvar "CMDECHO" 0)
  (setvar "OSMODE" 0)
  (setq laynam (getstring " Enter the Ski layer :"))
  (setq sec_tsp(getstring " Enter the TSP layer :"))
  (setq skiinfo(ssget "x" (list(cons 0 "LWPOLYLINE,POLYLINE")(cons 8 laynam))))
  (if skiinfo
    (progn
 
  (setq cnnt 0)
 
  (setq ftsp nil)
  (repeat (sslength skiinfo)
    (setq ski_plinfo(entget(ssname skiinfo cnnt)))
    (setq ski_fpt(cdr(assoc 10 ski_plinfo)))
    (setq ftsp(ssget "_C" ski_fpt ski_fpt(list(cons 0 "POINT")(cons 8 sec_tsp))))
    (setq ski_rev(reverse ski_plinfo))
    (setq ski_lpt(cdr(assoc 10 ski_rev)))
    (setq ltsp(ssget "_C" ski_lpt ski_lpt(list(cons 0 "POINT")(cons 8 sec_tsp))))
   
    (if (= ftsp nil)
           (create_circle ski_fpt 0.0002 "0" 4)

     )
    (if (= ltsp nil)
     
      (create_circle ski_lpt 0.0002 "0" 4)
     
      )
   
   
    (setq cnnt(+ cnnt 1))
    ))
   
(alert " SKI LAYER IS NOT A POLYLINE FEATURE")
    )
(setvar "CMDECHO" echo)
(setvar "OSMODE" osmode)

)
 

;-------------------------------------------------------------
    (defun create_circle (cir_pnt cir_radius la_name cir_color)
  (entmake
    (list
      (cons 0 "circle")
      (cons 10 cir_pnt)
      (cons 40 cir_radius)
      (cons 8 la_name)
      (cons 62 cir_color)

    )
  )
)


EDIT: Encapsulated the code in [ code ] tags for easier viewing
« Last Edit: August 17, 2006, 08:10:14 AM by nivuahc »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: capturing point features
« Reply #1 on: August 15, 2006, 05:19:49 AM »
works for me ... but ..

what style is the point entity ? .. does it actually pass through the endpoint ?

The selection crossing may be better as a box, just to make sure .. though it does work as it is ..

Localise your variables,
Code: [Select]
(DEFUN c:chk_ski (/ boxhalfsize circlesize box
  CNNT ECHO FTSP LAYNAM LTSP OSMODE SEC_TSP
                        SKIINFO SKI_FPT SKI_LPT SKI_PLINFO SKI_REV)
;;............

add this

Code: [Select]
(DEFUN _boxpoint (pt halfsize)
  (LIST (LIST (- (CAR pt) halfsize) (- (CADR pt) halfsize) 0)
(LIST (+ (CAR pt) halfsize) (+ (CADR pt) halfsize) 0)
  )
)

modify this
Code: [Select]
(PROGN (SETQ cnnt 0
             ftsp nil
             boxhalfsize 1
             circlesize 5
       )
       (REPEAT (SSLENGTH skiinfo)
         (SETQ ski_plinfo (ENTGET (SSNAME skiinfo cnnt))
               ski_fpt    (CDR (ASSOC 10 ski_plinfo))
               box        (_boxpoint ski_fpt 1)
               ftsp       (SSGET "_C"
                                 (CAR box)
                                 (CADR box)
                                 (LIST (CONS 0 "POINT") (CONS 8 sec_tsp))
                          )
               ski_rev    (REVERSE ski_plinfo)
               ski_lpt    (CDR (ASSOC 10 ski_rev))
               box        (_boxpoint ski_lpt 1)
               ltsp       (SSGET "_C"
                                 (CAR box)
                                 (CADR box)
                                 (LIST (CONS 0 "POINT") (CONS 8 sec_tsp))
                          )
         )
         (IF (NOT ftsp)
           (create_circle ski_fpt circlesize "0" 4)
         )
         (IF (NOT ltsp)
           (create_circle ski_lpt circlesize "0" 4)
         )
         (SETQ cnnt (+ cnnt 1))
       )
)



added
set the variables boxhalfsize and circlesize to values that suit you.
« Last Edit: August 15, 2006, 05:22:01 AM by Kerry Brown »
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.

viva

  • Guest
Re: capturing point features
« Reply #2 on: August 17, 2006, 03:34:23 AM »
hello kerry brown,
               thanks for ur immediate reply. watr i had understand from ur coding is that ur placing a box around the starting / ending point of the polyline. Then u r capturing the point data which lies within the box. i think this is a  logic that u had used.
                  but in my case the point data is exactly snap with eithier start/end point of the polyline. my task is to check whether the point data is exactly snapped or not. if its not there means i want 2 place a circle.

regards
vivek




works for me ... but ..

what style is the point entity ? .. does it actually pass through the endpoint ?

The selection crossing may be better as a box, just to make sure .. though it does work as it is ..

Localise your variables,
Code: [Select]
(DEFUN c:chk_ski (/ boxhalfsize circlesize box
  CNNT ECHO FTSP LAYNAM LTSP OSMODE SEC_TSP
                        SKIINFO SKI_FPT SKI_LPT SKI_PLINFO SKI_REV)
;;............

add this

Code: [Select]
(DEFUN _boxpoint (pt halfsize)
  (LIST (LIST (- (CAR pt) halfsize) (- (CADR pt) halfsize) 0)
(LIST (+ (CAR pt) halfsize) (+ (CADR pt) halfsize) 0)
  )
)

modify this
Code: [Select]
(PROGN (SETQ cnnt 0
             ftsp nil
             boxhalfsize 1
             circlesize 5
       )
       (REPEAT (SSLENGTH skiinfo)
         (SETQ ski_plinfo (ENTGET (SSNAME skiinfo cnnt))
               ski_fpt    (CDR (ASSOC 10 ski_plinfo))
               box        (_boxpoint ski_fpt 1)
               ftsp       (SSGET "_C"
                                 (CAR box)
                                 (CADR box)
                                 (LIST (CONS 0 "POINT") (CONS 8 sec_tsp))
                          )
               ski_rev    (REVERSE ski_plinfo)
               ski_lpt    (CDR (ASSOC 10 ski_rev))
               box        (_boxpoint ski_lpt 1)
               ltsp       (SSGET "_C"
                                 (CAR box)
                                 (CADR box)
                                 (LIST (CONS 0 "POINT") (CONS 8 sec_tsp))
                          )
         )
         (IF (NOT ftsp)
           (create_circle ski_fpt circlesize "0" 4)
         )
         (IF (NOT ltsp)
           (create_circle ski_lpt circlesize "0" 4)
         )
         (SETQ cnnt (+ cnnt 1))
       )
)



added
set the variables boxhalfsize and circlesize to values that suit you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: capturing point features
« Reply #3 on: August 17, 2006, 08:04:11 AM »

There was no need to quote my code, I know what I wrote. I also explained the reason behind the method I was using.  Several of the "points" do not have a selectable part at their insertion insert, therefore if one of those points are used, the routine will report that there is nothing there.


I would have been good if you had explained your expected functionality in your first post .. when you say " working fine in some drawing and it is not working properly in many drawing" and nothing else there is not a lot we can do except guess.
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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: capturing point features
« Reply #4 on: August 17, 2006, 08:25:05 AM »
Quote
my task is to check whether the point data is exactly snapped or not. if its not there means i want 2 place a circle.

if this is your goal, you need to test for a "POINT", get its insert location, compare it to the line origin ... if your PDMODE is say 33 or 65 for instance. I asked and you didn't respond .. what style of point are you using ? ?
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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: capturing point features
« Reply #5 on: August 17, 2006, 08:27:51 AM »
 .. and all points except one may pass your ssget location test and still NOT have their insertion at the ssget location.

.. just a warning .. 
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.

viva

  • Guest
Re: capturing point features
« Reply #6 on: August 18, 2006, 12:38:58 AM »
hi kerry brown

        thanks for ur suggestion. in the drawing PDMODE is 65. if u dont mind can u explain me little bit breifly abut ur last post.

regards
vivek
           

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: capturing point features
« Reply #7 on: August 18, 2006, 01:04:16 AM »
It's pretty simple ..
some of the 'points' do not have anything selectable at their insertion node, so if you do a ssget at that point you will not be able to select the point object.

For example, in the SELECT piccy, the green area is the crossing selected, butONLY the line will be selected because the POINT entity does not cross the end of the line.  This may be your problem ... be sure to use a PDMODE like 66 which actually passes through the insert node.
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.