Jump to content

Finally selecting objects inside complex polylines accurately (no zoom out required)


cluelessguy

Recommended Posts

Hello,

 

today I'm sharing with you a piece of code that does just what the title says,

I couldn't find one so I "made" one.

This piece of code selects TEXT inside polylines, and tosses the area of those polylines along with text to a text file recognizable by excel.

 

But you can use to select any object you want and do whatever you want with it.

I just applied the algorithm suggested by ASMI here

To a code from Tharwat here that already handled rays and intersections and was already very optimized.

Thank you Tharwat if it wasn't for your code it was going to get really messy here.

 

anyways here goes the code:

(defun c:Pl_Area+Id (/ *error* spc ents ang e p ray ss i n txtsel fnm file d)
 (vl-load-com)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Cluelessguy 16. Nov. 2013                                                                              ;;
;; Inspired From ASMI's suggestion here goo.gl/VN0gS5                                                     ;;
;; Modified from Tharwat's code from this post goo.gl/ZDDjlV                                              ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This code should should associate every Text from layer "ID" along with the Polyline from layer "Poly" ;;
;; that surrounds it, and output the area of the Polyline along with the Text inside it to a txt file     ;;
;; that can be opened in Excel.                                                                           ;;
;; Make sure all your Polylines are closed before running the code.                                       ;;
;; Text intersecting the Polyline(s) will be filtered out.                                                ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; You can use this method to select objects inside polyline accurately for whatever your purpose is,     ;;
;; just modify the ssget filters and replace (write-line ...) with whatever you'd like to do with it.     ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (defun *error* (x) (princ "\n") (princ "\n *Cancel*") (princ x))
 (or acdoc (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))))
 (setq spc (if (> (vla-get-ActiveSpace acdoc) 0)
             (vla-get-Modelspace acdoc)
             (vla-get-paperspace acdoc)
           )
 )
 (if (setq ss (ssget "_x" '((0 . "*POLYLINE") (8 . "Poly") (-4 .   "&") (70 . 1) (-4 . "<NOT") (-4 . "&") (70 . 80) (-4 .   "NOT>"))))
   (repeat (setq i (sslength ss))
     (setq ents (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ents))
   )
 )
 (if (setq ang 1
             txtsel (ssget "_x" '((0 . "*TEXT") (8 . "ID")))
             fnm     (getfiled "Please enter a name for the output file" (getvar 'DWGPREFIX) "txt" 1)
     )
   (progn
     (setq file (open fnm "w"))
     (repeat (setq n (sslength txtsel))
       (setq p (cdr (assoc 10 (entget (setq e (ssname txtsel (setq n (1- n))))))))
       (setq ray (vla-addray spc (vlax-3d-point p) (vlax-3d-point (polar p ang 1.))))
       (foreach ent ents
         (if (Isitinside e ent ray)
           (write-line
               (strcat (cdr (assoc 1 (entget e))) "\t" (rtos (vlax-curve-getArea ent) 2 2))
               file
           )
         )
       )
       (vla-delete ray)
     )
   (close file)
   )
   (princ)
 )
 (startapp "explorer" (strcat "/n,/e," fnm))
 (princ "\nDone!")
 (princ)
)
(defun Isitinside ( objent pl ray / in)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This code checks if the objects is inside the Polyline (and NOT intersecting it)        ;;
;; and returns T if it is and nil if not.                                                  ;;
;;                                                                                         ;;
;;The arguments are:                                                                       ;;
;;                                                                                         ;;
;; objent : the ename of the object potentially inside the polyline                        ;;
;; pl     : the ename of the polyline converted to a vla-object                            ;;
;; ray    : a ray starting from the object potentially inside the polyline as a vla-object ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   (if (and 
           (not (vlax-invoke (vlax-ename->vla-object objent)   'Intersectwith pl acExtendNone)) ;; Checks if the object intersects the   polyline, I wouldn't recommend removing this line.
           (setq in (vlax-invoke ray 'Intersectwith pl acExtendNone))                           ;; Checks if the ray intersects the polyline.
           (/= (rem (/ (length in) 3) 2) 0)                                                     ;; Checks how many times the ray intersects the   polyline, if it's an odd number, it's inside; if it's an even number,   then it's outside;
       )                                                                                        ;; that is why we filter out objects   intersecting the polylines, the object has to be either inside or   outside for this to work.
       t
   )
)
(princ "\nType Pl_Area+Id to invoke")
(princ)

Tell me what are your thoughts, and feel free to twist it however you like and post the outcome as a reply or start a thread.

 

regards.

Edited by cluelessguy
Link to comment
Share on other sites

I wish I were clueless too!:o

First of all, it's a verry impressing code.

 

[EDIT: removed my proposal for first ssget-filter, didn't noticed the difference between "&" and "AND"]

 

Running a quick check (see attachment), I noticed that there will be some unexpacted results if a text-entity is surrounded by more than one polyline, see attachment.

No worry about that, suggesting doing floorplans, a room is seldom surround by two :D

A great programm, maybee quite usefull to analyze drawings, where informations are only stored as "text".

This can be older ones, but also exports from vertical addons.

 

Thanks for sharing it!

 

regards

Wolfgang

test.dwg

Edited by wkplan
Link to comment
Share on other sites

Hello,

 

Wolfgang, you are most welcome my friend, and thank you for taking the time to reply :)

 

pBe, you are most welcome, and it should work no matter how irregular the polylines are, as long as they make it through the filter. Just make sure they are closed from the properties window, they often look closed but in fact they're not, I was getting that a lot when I was testing.

 

However the code is not perfectly accurate if the ray is tangent to a polyline, like this for example

Capture_2.jpg

you'd have to leave it for luck (or try the flowing slower but more precice version of the code)

This is probably overkill, the code in the first post with the right angle should be enough, unless you have some really complex polylines (still nothing that can't be fixed by trying a different angle). But just in case you have a LOT of objects to deal with, and have some time on your hand and don't wan't to bother check after it's done weather every thing is correct, this is the code for you

(defun c:Pl_Area+Id (/ *error* spc ents ang e p ray ss i n idx l tang isin txtsel fnm file d)
 (vl-load-com)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Cluelessguy 18. Nov. 2013                                                                                ;;
;; Inspired From ASMI's suggestion here http://goo.gl/VN0gS5                                              ;;
;; Modified from Tharwat's code from this post http://goo.gl/ZDDjlV                                          ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This code should should associate every Text from layer "ID" along with the Polyline from layer "Poly" ;;
;; that surrounds it, and output the area of the Polyline along with the Text inside it to a txt file      ;;
;; that can be opened in Excel.                                                                              ;;
;; Make sure all your Polylines are closed before running the code.                                          ;;
;; Text intersecting the Polyline(s) will be filtered out.                                                   ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; You can use this method to select objects inside polyline accurately for whatever your purpose is,       ;;
;; just modify the ssget filters and replace (write-line ...) with whatever you'd like to do with it.      ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (defun *error* (x) (if file (progn (close file) (vl-file-delete fnm))) (if ray (vla-delete ray)) (princ "\n") (princ "\n *Error* ==> ") (princ x))
 (or acdoc (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))))
 (setq spc (if (> (vla-get-ActiveSpace acdoc) 0)
             (vla-get-Modelspace acdoc)
             (vla-get-paperspace acdoc)
           )
 )
 (if (setq ss (ssget "_x" '((0 . "*POLYLINE") (8 . "Poly") (-4 . "&") (70 . 1) (-4 . "<NOT") (-4 . "&") (70 . 80) (-4 . "NOT>")))) ; Gets all CLOSED polylines in layer Poly except for 3D ones.
   (repeat (setq i (sslength ss))
     (setq ents (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ents)) ;convert the selected polylines to vla-objects and assemble them together in a list.
   )
 )
 (if (setq ang (getangle "\nSpecify an angle :") ; The direction where the ray is facing, any would do.
           txtsel (ssget "_x" '((0 . "*TEXT") (8 . "ID"))) ;Gets all TEXTs from layer ID.
           fnm     (getfiled "Please enter a name for the output file" (getvar 'DWGPREFIX) "txt" 1) ;the output file.
     )
   (progn
     (setq file (open fnm "w") ;Opens the file for writing.
             n (- (sslength txtsel) 1) ;number of TEXT entities in the selection set.
             l (length ents) ;number of Polylines in the Polylines list.
     )
     (write-line "ID\tArea" file) ;write the headers to the file.
     (while (and (not tang) (> n -1)) ;Keep running until a tangent has been found, or we run out of TEXT entities.
       (setq p (cdr (assoc 10 (entget (setq e (ssname txtsel n))))) ; the coordinates of the insertion point of the text.
             ray (vla-addray spc (vlax-3d-point p) (vlax-3d-point (polar p ang 1.))) ; Draw a ray from the text insertion point at the angle specified earlier.
             idx 0 ;index number
       )
       (while (and (not tang) (< idx l)) ;Keep running until a tangent has been found, or we run out of Polylines.
         (setq ent (nth idx ents))
         (if (eq (setq isin (Isitinside e ent ray)) "in") ;If the text is inside, then write the text string and the area of the Polyline to our file.
             (write-line
               (strcat (cdr (assoc 1 (entget e))) "\t" (rtos (vlax-curve-getArea ent) 2 2))
               file
             )
             (if (eq isin "tan") ;If it is not inside, then if it is tangent, alert the user to retry with a different angle (otherwise continue to the next text entity).
                   (progn
                       (setq tang t)
                       (alert "The ray is tangent to one of the Polylines! retry with a different angle.")
                   )
             )
         )
         (setq idx (1+ idx))
       )
       (vla-delete ray)
       (setq n (- n 1))
     )
   (close file) ;no need to explain.
   (if tang (vl-file-delete fnm)) ;if a tangent has been found, you are going to retry with a different angle anyway, so why keep the file.
   )
   (princ)
 )
 (if (not tang) (startapp "explorer" (strcat "/n,/e," fnm))) ;Open the file unless is has been deleted.
 (princ "\nDone!") ; 
 (princ)
)
(defun Isitinside ( objent pl ray / in istan)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This code checks if the objects is inside the Polyline (and NOT intersecting it)           ;;
;; and returns "in" if it is in, and "tan" if it is tangent, and nl if t is out.           ;;
;;                                                                                            ;;
;;The arguments are:                                                                       ;;
;;                                                                                           ;;
;; objent : the ename of the object potentially inside the polyline                        ;;
;; pl      : the ename of the polyline converted to a vla-object                             ;;
;; ray      : a ray starting from the object potentially inside the polyline as a vla-object ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   (if (and (not (vlax-invoke (vlax-ename->vla-object objent) 'Intersectwith pl acExtendNone)) ; Checks if the object intersects the polyline, I wouldn't recommend removing this line.
            (setq in (vlax-invoke ray 'Intersectwith pl acExtendNone)) ; Checks if the ray intersects the polyline.
            (not (setq istan (IsitTangent in (vlax-get pl 'Coordinates)))) ; Checks if it's not tangent, if it is the number of intersections wouldn't be accurate. 
            (/= (rem (/ (length in) 3) 2) 0) ; Checks how many times the ray intersects the polyline, if it's an odd number, it's inside; if it's an even number, then it's outside;
       )                                      ; that is why we filter out objects intersecting the polylines, the object has to be either inside or outside for this to work.
       (princ "in")
       (if istan
           (princ "tan")
       )        
   )
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This one checks if the ray is tangent the Polyline segemnts                                ;;
;; returns T if it is and nil if not.                                                        ;;
;;                                                                                            ;;
;;The arguments are:                                                                       ;;
;;                                                                                           ;;
;; ints       : list of intersection points from the vba IntersectWith method               ;;
;; coors      : list of vertex coordinates from the vba Coordinates method                 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun IsitTangent (ints coors / intlst vlst l ItIs)
 (setq coorlst (coordinates->list coors) ;Convert that weird list to a normal xyz coordinates list
         intlst     (intersects->list ints) ;Same thing with here
       vlst     (vl-remove-if-not '(lambda (x) (member x coorlst)) intlst) ;Filter out intersection points that are not intersecting the polyline vertices
 )
 (if (> (setq l (length vlst)) 1)
     (while (and (not ItIs) (> l 1)); while not tangent, and not out of points, keep checking
       (if (= 1    ; if two of those intersetions points or/and vertices points are one after the other, then bingo, the ray is tangent
             (abs 
               (-
                 (vl-position (nth (- l 1) vlst) coorlst)
                 (vl-position (nth (- l 2) vlst) coorlst)
               )
             )
           )
             (setq ItIs t) ;if the ray is tangent then set ItIs to true
             (setq l (- l 1)) ; get to the next point on the list
       )
     )
 )
 (if ItIs t) ;if the ray is tangent then return true (otherwise nil)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This one converts that weirdly appended list of vertices coordinates into a normal list ;;
;; returns a list like this (x y 0.0)                                                       ;;
;;                                                                                            ;;
;;The arguments are:                                                                       ;;
;;                                                                                           ;;
;; coors      : list of vertex coordinates from the vba Coordinates method                 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun coordinates->list (coor / lst)
(while (> (length coor) 0)
  (setq lst (cons (list (car coor) (cadr coor) 0.) lst)
        coor (cddr coor)
  )
)
lst
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This one does the same thing as the previous one except for th intersections coordinates ;;
;; i have them separated because IntersectWith returns x y and z while Coordinates returns  ;;
;; only x and y.                                                                              ;;
;;                                                                                             ;;
;;The arguments are:                                                                        ;;
;;                                                                                            ;;
;; ints       : list of intersection points from the vba IntersectWith method                ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun intersects->list (in / lst)
(while (> (length in) 0)
  (setq lst (cons (list (car in) (cadr in) 0.) lst)
         in  (cdddr in)
  )
)
lst
)
(princ "\nType Pl_Area+Id to invoke")
(princ)

Any suggestions to how to make it faster are more than welcome.

Edited by cluelessguy
missing closing parenthesis, sorry about that :)
Link to comment
Share on other sites

I couldn't find one so I "made" one.

Why not use ssget "WP" Autocad does all the hardwork no code required !! I posted some code here previously some time ago that found the text within multiple polylines and outputted to a text file.

 

Heres a copy

(defun getcoords (ent)
 (vlax-safearray->list
   (vlax-variant-value
     (vlax-get-property
   (vlax-ename->vla-object ent)
   "Coordinates"
     )
   )
 )
)

(defun co-ords2xy ()
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq numb (/ (length co-ords) 2))
(setq I 0)
(repeat numb
(setq xy (list (nth I co-ords)(nth (+ I 1) co-ords) ))
(setq coordsxy (cons xy coordsxy))
(setq I (+ I 2))
) ; end repeat
) ; end defun
; program starts here
; choose output file change acdatemp to what you want
(setq fname (strcat "c:/acadtemp/" (getstring "\nEnter file name ")))
(setq fout (open fname "w"))
(setq plobjs (ssget (list (cons 0 "lwpolyline"))))
(setq numb1 (sslength plobjs))
(setq x numb1)
(repeat numb1
(setq obj (ssname plobjs (setq x (- x 1))))
(setq co-ords (getcoords obj))
(co-ords2xy)
; write pline co-ords here
(setq numb3 (length co-ords))
(setq z numb3)
(setq ansco-ords "")
(repeat numb3 
(setq ansco-ords (strcat ansco-ords (rtos (nth (setq z (- z 1)) co-ords) 2 3 ) " " ))
)
(setq ans (strcat "Pline " ansco-ords))
(write-line ans fout)
(setq ansco-ords "")
(setq ss (ssget "WP" coordsxy (list (cons 0 "Text,Mtext")))) ; selection set of text within polygon
(if (= ss nil) 
(princ "\nnothing inside")
(progn 
(setq coordsxy nil) ; reset for next time
(setq numb2 (sslength ss))
(setq y numb2)
(repeat numb2
(setq anstext (vlax-get-property (vlax-ename->vla-object (ssname ss (setq y (- y 1)))) "Textstring"))
(princ anstext) ; change to write text to file
(write-line (strcat "text " anstext) fout)
(princ "\n")
) ; end repeat2
(setq ss nil) ; reset for next poly
)
)
) ; end repeat1
(close fout)
(princ)

Link to comment
Share on other sites

BIGAL,

 

imho ssget won't work well, if the displayed area is verry big and the "selection zone" is rather small.

(Must be some issue with the display-list driver/concept).

Workaround for this is almost to zoom to the selection-polygon before make a ssget-call. Looks funny if those programs run on large drawings :D, but seems to work fine.

 

Cluelessguy showed a way to avoid this problem, many thanks to him.

 

In fact I've seen some pretty cool code, at first look working like a charme, but at second producing some unexepected results...

... all dealing with ssget CP/WP

 

Looking at youre code, I can't see how the program is started, is there a hint?

 

regards

Wolfgang

Link to comment
Share on other sites

This is my modification of Alan J. Thompson's code...

 

(defun c:SSIO ( / *error* _p2ss _Pnt cmd ucs o o- o+ ent u ssIn ssOut )
 ;; Select Inside/Outside of selected LWPolyline
 ;; Alan J. Thompson, 04.02.10

 (vl-load-com)

 (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
 (or *SSIO:Opt* (setq *SSIO:Opt* "Inside"))

 (defun *error* (#Message)
   (and ucs (vl-cmdf "_.ucs" "_p"))
   (and cmd (setvar 'cmdecho cmd))
   (and *AcadDoc* u (vla-endundomark *AcadDoc*))
   (and #Message
        (not (wcmatch (strcase #Message) "*BREAK*,*CANCEL*,*QUIT*"))
        (princ (strcat "\nError: " #Message))
   ) ;_ and
 ) ;_ defun

 (setq _p2ss (lambda (ename meth)
               (ssget meth
                      ((lambda (e / l)
                         (foreach x e (and (eq 10 (car x)) (setq l (cons (cdr x) l))))
                         l
                       ) ;_ lambda
                        (entget ename)
                      )
               ) ;_ ssget
             ) ;_ lambda
       _Pnt  (lambda (e s / e o l p)
               (setq e (vlax-ename->vla-object e))
               (setq p (vlax-curve-getendpoint
                         (caar (vl-sort
                                 (cons
                                   (cons e (vla-get-area e))
                                   (setq l (mapcar
                                             (function
                                               (lambda (# / o)
                                                 (if (setq
                                                       o
                                                        (car
                                                          (vlax-safearray->list
                                                            (vlax-variant-value (vla-offset e (* # 0.01)))
                                                          ) ;_ vlax-safearray->list
                                                        ) ;_ car
                                                     ) ;_ setq
                                                   (cons o (vla-get-area o))
                                                 ) ;_ if
                                               ) ;_ lambda
                                             ) ;_ function
                                             '(-1. 1.)
                                           ) ;_ mapcar
                                   ) ;_ setq
                                 ) ;_ cons
                                 (function (lambda (a b) (s (cdr a) (cdr b))))
                               ) ;_ vl-sort
                         ) ;_ caar
                       ) ;_ vlax-curve-getendpoint
               ) ;_ setq
               (mapcar
                 (function (lambda (x) (vl-catch-all-apply (function vla-delete) (list (car x)))))
                 l
               ) ;_ mapcar
               p
             ) ;_ lambda
 ) ;_ setq

 (and (setq o (car (entsel "\nSelect LWPolyline: ")))
      (or (eq "LWPOLYLINE" (cdr (assoc 0 (setq ent (entget o)))))
          (alert "Invalid object!")
      ) ;_ or
      (not (initget 0 "Inside Outside"))
      (setq *SSIO:Opt*
             (cond
               ((getkword (strcat "\nSpecify select option [inside/Outside] <" *SSIO:Opt* ">: ")))
               (*SSIO:Opt*)
             ) ;_ cond
      ) ;_ setq
      (setq u (not (vla-startundomark *AcadDoc*)))

      (setq cmd (getvar 'cmdecho))
      (setvar 'cmdecho 0)
      (or (not (zerop (getvar 'worlducs)))
          (setq ucs (vl-cmdf "_.ucs" ""))
      ) ;_ or

      (cond
        ((eq *SSIO:Opt* "Inside")
         (command "_.offset" "_T" o "_non" (_pnt o <) "")
         (setq o- (entlast))
         (setq ssIn (_p2ss o- "_CP"))
         (entdel o-)
         (sssetfirst nil ssIn)
        )

        ((eq *SSIO:Opt* "Outside")
         (command "_.offset" "_T" o "_non" (_pnt o >) "")
         (setq o+ (entlast))
         (setq ssIn  (_p2ss o+ "_CP")
               ssOut (ssget "_X" (list (cons 410 (getvar 'ctab))))
         )
         (if ssIn (setq ssOut (acet-ss-remove ssIn ssOut)))
         (entdel o+)
         (sssetfirst nil ssOut)
        )
      ) ;_ cond
 ) ;_ and
 (*error* nil)
 (princ)
) ;_ defun

M.R.

 

Of course, LWPOLYLINE must be POLYGON - must not have arcs and before you start SSIO, complete polygon must be in visible area of ACAD screen...

Link to comment
Share on other sites

Hello guys,

 

pBe, it didn't seem like it, but your Mtext is intersecting the polyline see here

Capture_1.jpg

 

BIGAL, As wkplan said, it just didn't work out well between me and ssget, It just doesn't do it right. One day I really needed the job done and I got frustrated to the point that I decided to do it all manually, and that's what got me started on this quest.

 

marko_ribar, That looks like a fairly complex routine I'll give a shot an try to understand what it does (later today when i get time), I'm still a newbie after all :D, I've only known about lisp for two months now, and I'm still learning.

Edited by cluelessguy
Link to comment
Share on other sites

...pBe, it didn't seem like it, but your Mtext is intersecting the polyline see here

 

I see, good catch dude. I suggest to add a shrinkwrap sub on your routine to take care of that condition then. .

 

Cheers Cluelessguy :)

Link to comment
Share on other sites

Theres often not just a solution out of the box my code was done for someone posting here and again it had niggly problems like if text was within two polygons then it was found twice. Its always a problem that you need it now and as you say sometimes trying to get code working its better to just do it and fix the code later for next time. Its suprising though how many cut and paste of code can help in other situations so I am for ever saving snippets that may be usefull there is a lot smarter than me people here.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...