Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;1. dokonać selekcji poligonalnej, obiekty muszą się w całości mieścić w oknie
  2. ;2. pozostawić tylko te, których sumaryczne pole >460
  3. ;3. dodać warstwę "wynik" i przenieść na nią selekcję
  4. ;4. wyłączyć pozostałe warstwy
  5.  
  6. ;1. Create a polygonal selection. The selected objects have to be completly inside the selection
  7. ;2. Leave only those, whose total area is > 460
  8. ;3. Add a layer "result" and move the selection to it
  9. ;4. Disable/hide the other layers
  10.  
  11. (defun ConvList_to_VariantArray (InList SAType /  LengthList iCount iList)
  12.  
  13.     (setq LengthList (length InList))
  14.     (setq OutSaveArray (vlax-make-safearray SAType (cons 0 (1- LengthList) )))  ;;;   '(l-bound . u-bound)
  15.         (setq iCount 0)
  16.     (repeat  LengthList
  17.         (setq iList (nth iCount InList))
  18.             (vlax-safearray-put-element OutSaveArray  iCount  iList)
  19.    
  20.         (setq iCount (1+ iCount))
  21.     ); end repeat
  22.  
  23.   (vlax-make-variant   OutSaveArray )           ; return this value.
  24. )
  25.  
  26. ;; zad1
  27. (setq application (vlax-get-acad-object))
  28. (setq *ActiveDocument* (vla-get-activedocument application))
  29. (setq *SelectionSets* (vla-get-SelectionSets *ActiveDocument*)); - get the selectionset / pobranie kolekcji selectionsets
  30. (vla-Add *SelectionSets* "SelAll");
  31. (setq SelAll (vla-item *SelectionSets* "SelAll" ))
  32.                                    
  33. (repeat 5
  34.   (setq points_list (append points_list  (getpoint)))
  35.   )
  36.  
  37. ;(43 3244 543 645 577 876)
  38. (setq FilterType nil FilterData nil)
  39. (setq FilterType (ConvList_to_VariantArray (list 8) vlax-vbInteger))
  40. (setq FilterData (ConvList_to_VariantArray (list (vlax-make-variant "0")) vlax-vbVariant))
  41. (vla-clear SelAll)
  42. (vla-SelectByPolygon SelAll acSelectionSetWindowPolygon (ConvList_to_VariantArray  points_list vlax-vbDouble) FilterType FilterData)
  43. ;;zad2
  44. (setq todelete nil)
  45. (setq mspace (vla-get-modelspace *ActiveDocument*))
  46. (setq blocksL nil)
  47. (vlax-for item mspace
  48.   (if (= (vla-get-objectname item) "AcDbBlockReference")
  49.     (setq blocksrefL (append blocksrefL (list item)))
  50.     )
  51.   )
  52. (setq blockarea nil)
  53. (setq area 0)
  54. (foreach oneblok blocksrefL
  55.     (vlax-for item oneblok
  56.         (if (= (vlax-property-available-p item 'Area) T)
  57.         (progn
  58.             (setq area_of_element (vla-get-area  item))
  59.             (setq area (+ area area_of_element ))
  60.           )
  61.           )
  62.         )
  63.   (setq area 0 )
  64.   (setq blockarea (append  blockarea (list (list oneblok area))))
  65.   )
  66.  
  67. (vlax-for item Selall
  68.   (foreach itemsres blockarea
  69.     (if (= (vla-get-objectID item) (vla-get-objectID (nth 0 itemsres)))
  70.         (progn
  71.         (if (> (nth 1 itemsres) 460 )
  72.             (setq todelete (append todelete item)) 
  73.           )
  74.       )
  75.       )
  76.     )
  77.   )
  78.  
  79. ;;;(setq todelete nil)
  80. ;;;(vlax-dump-object SelAll t   )
  81. ;;;(vlax-for itemall SelAll
  82. ;;; (setq atributes (vla-GetAttributes itemall))
  83. ;;; (setq atributesSA (variant-value atributes))
  84. ;;; (setq atributesL (safearray-value atributesSA))
  85. ;;;     (if  (/= (vla-get-textstring (nth 0 atributesL))  nazwa_jabka)
  86. ;;;         (setq todelete (append todelete (list itemall)))
  87. ;;;      
  88. ;;;           )
  89. ;;;
  90. ;;;   )
  91. ;;;; do suswanie elementów z slekcji
  92. ;;;(setq NObj (length todelete))
  93. ;;;(setq SelObjArray (vlax-make-safearray vlax-vbObject   (cons 0 (1- NObj) )));zmiana listy na variant typu SafeArray:
  94. ;;;(setq iCount 0)
  95. ;;; (repeat NObj
  96. ;;;     (setq iList (nth iCount todelete))
  97. ;;;     (vlax-safearray-put-element SelObjArray iCount iList)
  98. ;;;     (setq SelObjArrayVar (vlax-make-variant SelObjArray))
  99. ;;;     (setq iCount (1+ iCount))
  100. ;;;   )
  101. ;;;
  102. ;;;
  103. ;;;(vla-RemoveItems  SelAll SelObjArrayVar)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement