Author Topic: Selecting objects by "cp" method  (Read 2078 times)

0 Members and 1 Guest are viewing this topic.

csgoh

  • Newt
  • Posts: 176
Selecting objects by "cp" method
« on: January 14, 2006, 07:26:10 AM »
I use Autocad map 2004 and I am just puzzled as to why this particular dwg behaves. In this dwg, I have a close lwpolyline polygon and 3 lines inside the polygon. At command prompt, I entered erase and use the cp for select objects and I chose all the end points of the closed lwpolyline polygon.


Command: e ERASE
Select objects: cp
First polygon point: end of
Specify endpoint of line or [Undo]: end of
Specify endpoint of line or [Undo]: end of
Specify endpoint of line or [Undo]: end of
Specify endpoint of line or [Undo]: end of
Specify endpoint of line or [Undo]: end of
Specify endpoint of line or [Undo]:
3 found

It returns 3 objects. By right it should return 4 objects. Why is this happenning? Any ideas.

I also have written a function to selectby polygon and sometimes it returns a wrong number of objects. Any comments to improve this function is much welcome.
Code: [Select]
;; This set of codes is dervied from Kerry
;; wg:NewNameSelectionSet
;; USAGE:
;; (wg:NewNameSelectionSet "Name of SS")
;; Returns a vla-object of selection set
;; 26-12-05
;;
(defun wg:NewNameSelectionSet(SelSetName / ssCollection)
  (setq ssColection (vla-get-selectionsets GB:ActivedocumentObj))
  (setq SelSetName (vlax-make-variant SelSetname))
  (if (vl-catch-all-error-p
        (vl-catch-all-apply 'vla-item (list ssColection SelSetName))
      )
      (vla-add ssColection SelSetName)
    (progn
      (vla-delete (vla-item ssColection SelSetName))
      (vla-add ssColection SelSetName)
    )
  ) ;_if
); wg:NewNameSelectionSet



(defun ListToSafearray (symVariableType lstValues / safValues)
 (setq safValues (vlax-make-safearray symVariableType
                  (cons 0 (1- (length lstValues)))))
 (vlax-safearray-fill safValues lstValues)
; safValues
) ;listToSafeArray

;;
;; GetObjectsByPolygon
;; USAGE:
;; Arguments
;; GB:ActivedocumentObj  - <VLa-object (active document obj)>
;; whatobjects           - <List of dotted pairs of entities to filter>
;;                          eg. (list '(0 . "LINE"))
;;                          eg. (list '(-4 . "<OR")'(0 . "LINE")
;;                                    '(0 . "LWPOLYLINE")'(0 . "POLYLINE")
;;                                    '(-4 . "OR>")
;;                              )
;; PointList             - <variant safearray 3D coords>
;; Mode?                 - <2>  acSelectionSetfence
;; Mode?                 - <6>  acSelectionSetWindowPolygon
;; Mode?                 - <7>  acSelectionSetCrossingPolygon
;; Returns a list of the VLA-objects filtered objects
;;
(defun wg:GetObjectsByPolygon-list
                               ( GB:ActivedocumentObj whatobjects PointList
                                  mode?
                                / objects-list ssObj
                                filter_codelist filter_valuelist
                                filter_code    filter_value
                               )

  (setq ssObj (wg:NewNameSelectionSet "SS1")
        filter_codelist  (mapcar '(lambda (x) (car x)) whatobjects)
        filter_valuelist (mapcar '(lambda (x) (cdr x)) whatobjects)
        filter_code  (ListtoSafearray 2 filter_codelist)
        filter_value (ListtoSafearray 12 filter_valuelist)
  )
  (vla-SelectByPolygon ssobj mode? PointList filter_code filter_value)
  (setq objects-list '())
  (vlax-for eachobj ssobj
   (setq objects-list(cons eachobj objects-list))
  )
  objects-list
) ;_ wg:GetObjectsByPolygon-list