Jump to content

Selection Set that selects objects inside a Curved Polyline


Sambo

Recommended Posts

Hi Guys,

 

I just found some code that will select objects inside a curved polyline. What I'm trying to work out is what the number inside (selectinside e 100) actually does in this below code so I can use it more efficiently and not just have a stupid high number that makes my lisp run really slow (for example to make it work on my drawing, for some polys in my drawing i need to set it on 3000 to do what i want it to do)

 

 

(defun selectinside ( ent acc / i j l )
   (setq i (/ (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) acc)
         j (- i)
   )
   (repeat (fix acc)
       (setq l (cons (trans (vlax-curve-getpointatdist ent (setq j (+ j i))) 0 1) l))
   )
   (ssget "_WP" l)
)


(defun c:test ( / e )
   (if
       (and
           (setq e (car (entsel)))
           (member (cdr (assoc 0 (entget e))) '("CIRCLE" "ELLIPSE" "SPLINE" "LWPOLYLINE" "POLYLINE"))
       )
       (sssetfirst nil (selectinside e 100)) ;;;;the higher the number in  the more accurate the selection set is around curves (also the slower it will run)
   )
   (princ)
)
(vl-load-com) (princ)

Link to comment
Share on other sites

Its long been known to convert an arc or circle to a series of facets/lines, it depends on what your looking at, how close the other objects are to the pline edge. Sometimes using a double ssget can help use a "F" option with the facets will get objects that are touched and the "WP" option then remove duplicate entities from a combined selection set. 

 

Without some idea of what your looking at I would expect that a value of around 10 should work most times.

 

Post a dwg so we can have a look.

Link to comment
Share on other sites

So the 100 is saying divide up the polyline into 100 segments and generate points from that.

 

poly 1 has 5 points and wouldn't select anything between the blue and white

poly 2 has 50 points (selectinside e 50)

 

image.thumb.png.b752dfec57b147d8064ee5be49059018.png

 

If you are using this on polylines that have a large number of verities then their will be gaps. don't get me wrong iv used that form lee mac for a long time and didn't under stand what it was doing also. But when I finally had time to study what it was doing I came up with this.

 

BAD CODE - use RonjonP link

 

What my lisp does is makes a copy of the polyline and explodes it into its base entity's arcs and lines.

for the arcs its dividing them by x  and generates points. for lines it calculates the endpoints. adds all those points into a list for ssget "WP"

 

So the points on the shape would look like this.

image.png.16ebb78cb439e021c5cffa43c24f8103.png

 

Only adding 5 points if x=5 With larger verities polylines it only add points to where the arc's are. So you don't have to keep guessing the number for the function or generating more points for smaller polyines.

 

I would like to make x dynamic so it divides up larger arc more than smaller ones.

Edited by mhupp
  • Like 2
Link to comment
Share on other sites

4 minutes ago, ronjonp said:

 

I don't believe this is what I'm looking for. I need more points on large arks and less on small ones. I'm working on 1000 Lot + subdivisions and I need to be able to grab entities close large arks.  

Link to comment
Share on other sites

Both good ideas mhupp & ronjonp, saved me some time coding the bulge bit.

 

mhupp should be able to get pline vertices then check is segment an arc then divide into chords, adding points to the pline list I need to look into Joe -burke code more, also Lee has a good pull apart pline. 

 

Sambo if not working decrease the value of the angle to say 5 degrees, suggested is 10. Even try 2.5, @5 for 90 arc = 18 points.

Edited by BIGAL
  • Like 1
Link to comment
Share on other sites

6 minutes ago, Sambo said:

 

I don't believe this is what I'm looking for. I need more points on large arks and less on small ones. I'm working on 1000 Lot + subdivisions and I need to be able to grab entities close large arks.  

I think you did not test the code...

image.png.70205d774a7a336000d19472a29fde9e.png

Link to comment
Share on other sites

32 minutes ago, mhupp said:

So the 100 is saying divide up the polyline into 100 segments and generate points from that.

 

poly 1 has 5 points and wouldn't select anything between the blue and white

poly 2 has 50 points (selectinside e 50)

 

image.thumb.png.b752dfec57b147d8064ee5be49059018.png

 

If you are using this on polylines that have a large number of verities then their will be gaps. don't get me wrong iv used that form lee mac for a long time and didn't under stand what it was doing also. But when I finally had time to study what it was doing I came up with this.

 

;;----------------------------------------------------------------------------;;
;; ssget "WP" doesn't work well with arc this fixes it
(defun SELECTINSIDE (ent / poly obj len lst)
  (setq x 5) ;change this number to what you want to divide arc's by
  (setq poly (vlax-invoke (vlax-ename->vla-object ent) 'explode))
  (foreach obj poly
    (cond
      ((eq (vla-get-Objectname obj) "AcDbArc")
           (setq seg (/ (vla-get-arclength obj) x)) 
           (setq lst (cons (vlax-curve-getPointAtDist obj 0) lst))
           (setq len seg)
        (repeat (1- x)
          (setq lst (cons (vlax-curve-getPointAtDist obj len) lst))
          (setq len (+ len seg))
        )
        (vla-delete obj)
      )
      ((eq (vla-get-Objectname obj) "AcDbLine")
           (setq lst (cons (vlax-get obj 'StartPoint) lst))
           (vla-delete obj)
      )
    )
  )
  (setq SS1 (ssget "_WP" lst))
  ;(setq SS2 (ssget "_CP" lst)) ;used for testing if anything is crossing
)

 

What my lisp does is makes a copy of the polyline and explodes it into its base entity's arcs and lines.

for the arcs its dividing them by x  and generates points. for lines it calculates the endpoints. adds all those points into a list for ssget "WP"

 

So the points on the shape would look like this.

image.png.16ebb78cb439e021c5cffa43c24f8103.png

 

Only adding 5 points if x=5 With larger verities polylines it only add points to where the arc's are. So you don't have to keep guessing the number for the function or generating more points for smaller polyines.

 

I would like to make x dynamic so it divides up larger arc more than smaller ones.

 

 

Thankyou so much for taking the time to explain this and provide me with that code. This is exactly what I need!! 

 

I had a feeling that was what it was doing but I wasn't certain. 

  • Like 1
Link to comment
Share on other sites

2 minutes ago, ronjonp said:

I think you did not test the code...

image.png.70205d774a7a336000d19472a29fde9e.png

Oh!

You are correct. I didn't test the code, just read what it said. this looks like it will work too. 

Both are great solutions. This solves a problem I've been struggling with for years in our lisps.

 

Thankyou all so much.

Link to comment
Share on other sites

7 minutes ago, BIGAL said:

Both good ideas mhupp & ronjonp, saved me some time coding the bulge bit.

 

mhupp should be able to get pline vertices then check is segment an arc then divide into chords, I need to look into Joe -burke code more, also Lee has a good pull apart pline. 

 

Sambo if not working decrease the value of the angle to say 5 degrees, suggested is 10. Even try 2.5, @5 for 90 arc = 18 points.

 

Yes i was just looking at that before too

http://lee-mac.com/entitytopointlist.html

 

Link to comment
Share on other sites

3 minutes ago, Sambo said:

Oh!

You are correct. I didn't test the code, just read what it said. this looks like it will work too. 

Both are great solutions. This solves a problem I've been struggling with for years in our lisps.

 

Thankyou all so much.

Glad to help out. In the future test it out first before deciding it's not the solution. :beer:

 

Most of these problems have been solved in the last 25 years .. or at least searchable.

 

Edited by ronjonp
  • Agree 1
Link to comment
Share on other sites

I have searched this pretty extensively before and hadn't been able to find an effective solution for it. I am also self taught so my knowledge is lacking in certain areas (sometimes I struggle just trying to figure out how to run sample code).

 

The problem I'm facing now from an efficiency standpoint. I need far less points on smaller arcs then I do larger ones. I more so need a max error from the polyline for my WP.

 

For an arc with a radius of 3 and an arclength of say 7 a division of 5 would represent a maximum error from the polyline of around 0.083 but with an arc with a radius of 200 and an archlength of say 500 my maximum error from the polyline if i was to divide that arc by 5 would now be about 6.3 and I have both of these type of arcs in the polylines that i need to run selection sets for. With the smaller arc the division example above works fine for me but for the larger arc the WP is to far away from the line. I cant figure out how to make Joes one run for me but it looks like it works on angles so I'm guessing I will run into the same problem with both?

 

 

I know mathematically i can calculate "L" using "H" & "R" ("H" being the maximum error from the arc that I want) and then divide the "L" by the arclength of the arc I'm wanting to divide up to figure out how many segments i need to split that arc into to get the result I'm looking for, but I don't know how to put all that into code. 

 

image.png.f72fdd50815c3f66626248c46873f0fb.png

Edited by Sambo
Link to comment
Share on other sites

You have answered your own question  " need far less points on smaller arcs then I do larger ones. " just introduce a Cond that has steps for the radius various the length as per you have indicated in your image. Work out H.

(cond
((if (< h 3.0)(setq deg x)))
((if (< h 4.0)(setq deg y)))
((if (< h 6.0)(setq deg z)))
((if (=> h 6.01)(setq deg A)))
)>

 

 

 

  • Like 1
Link to comment
Share on other sites

 

On 18/11/2022 at 14:42, mhupp said:

 

;;----------------------------------------------------------------------------;;
;; ssget "WP" doesn't work well with arc this fixes it
(defun SELECTINSIDE (ent / poly obj len lst)
  (setq x 5) ;change this number to what you want to divide arc's by
  (setq poly (vlax-invoke (vlax-ename->vla-object ent) 'explode))
  (foreach obj poly
    (cond
      ((eq (vla-get-Objectname obj) "AcDbArc")
           (setq seg (/ (vla-get-arclength obj) x)) 
           (setq lst (cons (vlax-curve-getPointAtDist obj 0) lst))
           (setq len seg)
        (repeat (1- x)
          (setq lst (cons (vlax-curve-getPointAtDist obj len) lst))
          (setq len (+ len seg))
        )
        (vla-delete obj)
      )
      ((eq (vla-get-Objectname obj) "AcDbLine")
           (setq lst (cons (vlax-get obj 'StartPoint) lst))
           (vla-delete obj)
      )
    )
  )
  (setq SS1 (ssget "_WP" lst))
  ;(setq SS2 (ssget "_CP" lst)) ;used for testing if anything is crossing
)

 

I've noticed this code has a bug in it where it goes back to the first point of the arc in some instances instead of going to the last point (see attached imaged of the line i created for the selection set points list). How would I go about fixing this? It seems to be for arcs where the centroid of the arc is facing away from the inside of the polyline. 

 

image.thumb.png.202bb23ad3b4e780cefbeeb56b48087e.png

 

This is how the selection set is being created in those instances

image.thumb.png.68463f3bbb869808d3d1752c20b58bbd.png

 

On 18/11/2022 at 20:32, BIGAL said:

You have answered your own question  " need far less points on smaller arcs then I do larger ones. " just introduce a Cond that has steps for the radius various the length as per you have indicated in your image. Work out H.

(cond
((if (< h 3.0)(setq deg x)))
((if (< h 4.0)(setq deg y)))
((if (< h 6.0)(setq deg z)))
((if (=> h 6.01)(setq deg A)))
)>

 

 

 

 

Thanks Bigal, I've implemented this and it works quiet well. 

Edited by Sambo
Link to comment
Share on other sites

You can try this code:
It allows you to make a selection by object (line, arc, circle or heavy/light polyline)
For closed objects, you will be offered to do either by capture or by window.
For open objects this will be the default fence option.
Once the objects have been selected, it will be possible to invert the selection, ie to exclude the selected entities and take the rest.
For curvilinear objects, the selection points are calculated with a central angle of 1/36 of a radian (line 31&85 of the code), it's up to you to see if this resolution suits you.

(defun def_bulg_pl (ls lb flag_closed / ls lb rad a l_new)
  (if (not (zerop flag_closed)) (setq ls (append ls (list (car ls)))))
  (while (cadr ls)
    (if (zerop (car lb))
      (setq l_new (append l_new (list (car ls))))
      (progn
        (setq
          rad (/ (distance (car ls) (cadr ls)) (sin (* 2.0 (atan (abs (car lb))))) 2.0)
          a (- (/ pi 2.0) (- pi (* 2.0 (atan (abs (car lb))))))
        )
        (if (< a 0.0) (setq a (- (* 2.0 pi) a)))
        (if (or (and (< (car lb) 0.0) (> (car lb) -1.0)) (> (car lb) 1.0))
          (setq l_new (append l_new (reverse (cdr (reverse (bulge_pts (polar (car ls) (- (angle (car ls) (cadr ls)) a) rad) (car ls) (cadr ls) rad (car lb)))))))
          (setq l_new (append l_new (reverse (cdr (reverse (bulge_pts (polar (car ls) (+ (angle (car ls) (cadr ls)) a) rad) (car ls) (cadr ls) rad (car lb)))))))
        )
      )
    )
    (setq ls (cdr ls) lb (cdr lb))
  )
  (append l_new (list (car ls)))
)
(defun bulge_pts (pt_cen pt_begin pt_end rad sens / inc ang nm p1 p2 lst)
  (setq
    inc (angle pt_cen (if (< sens 0.0) pt_end pt_begin))
    ang (+ (* 2.0 pi) (angle pt_cen (if (< sens 0.0) pt_begin pt_end)))
    nm (fix (/ (rem (- ang inc) (* 2.0 pi)) (/ (* pi 2.0) 36.0)))
  )
  (repeat nm
    (setq
      p1 (polar pt_cen inc rad)
      inc (+ inc (/ (* pi 2.0) 36.0))
      lst (append lst (list p1))
    )
  )
  (setq
    p2 (polar pt_cen ang rad)
    lst (append lst (list p2))
  )
  (if (< sens 0.0) (reverse lst) lst)
)
(defun c:sel_by_object ( / ent dxf_ent typent closed lst l_bulg e_next key osmd opkb oapt vmin vmax minpt maxpt zt lst2 l_ent ss1 ss2 js_all tmp)
  (while (null (setq ent (entsel "\nChoice of entity: "))))
  (setq typent (cdr (assoc 0 (setq dxf_ent (entget (car ent))))))
  (cond
    ((eq typent "LWPOLYLINE")
      (setq
        closed (boole 1 (cdr (assoc 70 dxf_ent)) 1)
        lst (mapcar '(lambda (x) (trans x (car ent) 1)) (mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 10)) dxf_ent)))
        l_bulg (mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 42)) dxf_ent))
        lst (def_bulg_pl lst l_bulg closed)
      )
    )
    ((eq typent "POLYLINE")
      (setq
        closed (boole 1 (cdr (assoc 70 dxf_ent)) 1)
        e_next (entnext (car ent))
      )
      (while (= "VERTEX" (cdr (assoc 0 (setq dxf_next (entget e_next)))))
        (if (zerop (boole 1 223 (cdr (assoc 70 dxf_next))))
          (setq
            lst (cons (trans (cdr (assoc 10 dxf_next)) (car ent) 1) lst)
            l_bulg (cons (cdr (assoc 42 dxf_next)) l_bulg)
          )
        )
        (setq e_next (entnext e_next))
      )
      (setq
        lst (reverse lst)
        l_bulg (reverse l_bulg)
        lst (def_bulg_pl lst l_bulg closed)
      )
    )
    ((eq typent "LINE")
      (setq
        lst (list (trans (cdr (assoc 10 dxf_ent)) 0 1) (trans (cdr (assoc 11 dxf_ent)) 0 1))
        closed 0
      )
    )
    ((eq typent "CIRCLE")
      (setq
        lst
          (bulge_pts
            (trans (cdr (assoc 10 dxf_ent)) (car ent) 1)
            (polar (trans (cdr (assoc 10 dxf_ent)) (car ent) 1) 0.0 (cdr (assoc 40 dxf_ent)))
            (polar (trans (cdr (assoc 10 dxf_ent)) (car ent) 1) (- (* 2.0 pi) (/ (* pi 2.0) 36.0)) (cdr (assoc 40 dxf_ent)))
            (cdr (assoc 40 dxf_ent))
            1
          )
        lst (append lst (list (car lst)))
        closed 1
      )
    )
    ((eq typent "ARC")
      (setq
        lst
          (bulge_pts
            (trans (cdr (assoc 10 dxf_ent)) (car ent) 1)
            (polar (trans (cdr (assoc 10 dxf_ent)) (car ent) 1) (cdr (assoc 50 dxf_ent)) (cdr (assoc 40 dxf_ent)))
            (polar (trans (cdr (assoc 10 dxf_ent)) (car ent) 1) (cdr (assoc 51 dxf_ent)) (cdr (assoc 40 dxf_ent)))
            (cdr (assoc 40 dxf_ent))
            1
          )
        closed 0
      )
    )
    (T (princ "\nIs not a Line, Arc, Circle or Polyline!"))
  )
  (cond
    (lst
      (if (equal (last lst) (car lst)) (setq lst (cdr lst) closed 1))
      (setq osmd (getvar "osmode") oapt (getvar "aperture") opkb (getvar "pickbox"))
      (setvar "osmode" 0)
      (setq
        vmin (mapcar '- (getvar "viewctr") (list (/ (* (car (getvar "screensize")) (* 0.5 (getvar "viewsize"))) (cadr (getvar "screensize"))) (* 0.5 (getvar "viewsize")) 0.0))
        vmax (mapcar '+ (getvar "viewctr") (list (/ (* (car (getvar "screensize")) (* 0.5 (getvar "viewsize"))) (cadr (getvar "screensize"))) (* 0.5 (getvar "viewsize")) 0.0))
        minpt (list (eval (cons min (mapcar 'car lst))) (eval (cons min (mapcar 'cadr lst))))
        maxpt (list (eval (cons max (mapcar 'car lst))) (eval (cons max (mapcar 'cadr lst))))
      )
      (setq zt (or (< (car minpt) (car vmin)) (< (cadr minpt) (cadr vmin)) (> (car maxpt) (car vmax)) (> (cadr maxpt) (cadr vmax))))
      (if zt (command "_.zoom" "_window" minpt maxpt))
      (setvar "aperture" 1)
      (setvar "pickbox" 1)
      (if (zerop (getvar "pickfirst")) (setvar "pickfirst" 1))
      (while (car lst)
        (setq
          lst2 (cons (car lst) lst2)
          lst (vl-remove (car lst) lst)
        )
      )
      (setq lst (reverse lst2))
      (if (zerop closed)
        (setq ss1 (ssdel (car ent) (ssget "_F" lst)))
        (progn
          (initget "WPolygon CPolygon")
          (setq key (getkword "\nSelection by [WPolygon/CPolygon] <CP>: "))
          (if (eq key "WPolygon")
            (setq ss1 (ssget "_WP" lst))
            (setq ss1 (ssdel (car ent) (ssget "_CP" lst)))
          )
        )
      )
      (setvar "pickbox" opkb)
      (setvar "aperture" oapt)
      (setq
        l_ent (if ss1 (ssnamex ss1))
        js_all (ssget "_X")
      )
      (foreach n l_ent (if (eq (type (cadr n)) 'ENAME) (setq ss2 (ssdel (cadr n) js_all))))
      (if (and ss1 ss2 (= 0 (getvar "CMDACTIVE"))) 
        (progn
          (princ "\n<Click+left> to invert the selection; <Enter>/[Space]/Right+click to finish!.")
          (while (and (not (member (setq key (grread T 4 2)) '((2 13) (2 32)))) (/= (car key) 25))
            (sssetfirst nil ss1)
            (cond
              ((eq (car key) 3)
                (setq tmp ss1 ss1 ss2 ss2 tmp)
              )
            )
          )
        )
      )
      (setvar "osmode" osmd)
    )
  )
  (prin1)
)

 

Edited by Tsuky
  • Like 1
Link to comment
Share on other sites

12 hours ago, Sambo said:

I've noticed this code has a bug in it where it goes back to the first point of the arc in some instances instead of going to the last point (see attached imaged of the line i created for the selection set points list). How would I go about fixing this? It seems to be for arcs where the centroid of the arc is facing away from the inside of the polyline.

 

HUGE BUG im using what ronjonp posed from now on.

Link to comment
Share on other sites

8 hours ago, mhupp said:

 

HUGE BUG im using what ronjonp posed from now on.

I wouldn't have thought it was that huge? you can store the end point of the previous line in a variable and use that to check the direction of the arc when you hit one.. and if the acc is the first object in the poly just check it against the start point of the next line. That wouldn't work wouldnt it? 

 

Or is that code better in general? 

Link to comment
Share on other sites

@mhupp your codes fixed now. See Below

 

Note: This updated code now works on an approx. Sagitta distance instead of a number of segments (makes it easier for me to approximate polys with a more consistent error from the poly for the arks). I've also set the minimum number of segments for any ark at 4 (this will override the approx. Sagitta distance when needed).

 

(defun SELECTINSIDE (ent / obj poly polylen len counter Sagitta HalfCord ArcLen seg x)
  (Set_osmode nil)
  (setq lst nil)
  
  (setq poly (vlax-invoke (vlax-ename->vla-object ent) 'explode))
  (setq polylen (length poly))
  (setq counter 0)
  (setq Sagitta 0.5) ;;; max distance from the curve
  
  (while (< counter polylen)
    (cond
      ((eq (vla-get-Objectname (nth counter poly)) "AcDbArc")

           (setq HalfCord (sqrt (- (* 2 sagitta (vla-get-radius (nth counter poly))) (* sagitta sagitta))))
           (setq ArcLen (/ (* (* pi (+ (* HalfCord HalfCord) (* sagitta sagitta))) (RtD (asin (/ (* 2 HalfCord sagitta) (+ (* HalfCord HalfCord) (* sagitta sagitta)))))) (* 180.0 Sagitta)))
           (Setq x (ceil (/ (vla-get-arclength (nth counter poly)) ArcLen)))
		   (if (< x 4) (setq x 4))
           (setq seg (/ (vla-get-arclength (nth counter poly)) x))
           
           (if (/= counter 0)
		    (progn
			  (if (or (= (LM:roundm (distance (vlax-get (nth (- counter 1) poly) 'EndPoint) (vlax-get (nth counter poly) 'StartPoint)) 0.001) 0)
			          (= (LM:roundm (distance (vlax-get (nth (- counter 1) poly) 'StartPoint) (vlax-get (nth counter poly) 'StartPoint)) 0.001) 0))
              (progn
			    (setq lst (cons (vlax-get (nth counter poly) 'StartPoint) lst))
				(setq len 0)
                (repeat (1- x)
                   (setq len (+ len seg))
                   (setq lst (cons (vlax-curve-getPointAtDist (nth counter poly) len) lst))
                );end repeat
			  );end progn
			  (progn
			    (setq lst (cons (vlax-get (nth counter poly) 'EndPoint) lst))
				(setq len (vla-get-arclength (nth counter poly)))
				(repeat (1- x)
                   (setq len (- len seg))
                   (setq lst (cons (vlax-curve-getPointAtDist (nth counter poly) len) lst))
                );end repeat
			  );end progn else
			  );end if
			);end progn
			
			(progn
			  (if (or (= (LM:roundm (distance (vlax-get (nth (+ counter 1) poly) 'EndPoint) (vlax-get (nth counter poly) 'EndPoint)) 0.001) 0)
			          (= (LM:roundm (distance (vlax-get (nth (+ counter 1) poly) 'StartPoint) (vlax-get (nth counter poly) 'EndPoint)) 0.001) 0))
              (progn
			    (setq lst (cons (vlax-get (nth counter poly) 'StartPoint) lst))
				(setq len 0)
                (repeat (1- x)
                   (setq len (+ len seg))
                   (setq lst (cons (vlax-curve-getPointAtDist (nth counter poly) len) lst))
                );end repeat
			  );end progn
			  (progn
			    (setq lst (cons (vlax-get (nth counter poly) 'EndPoint) lst))
				(setq len (vla-get-arclength (nth counter poly)))
				(repeat (1- x)
                   (setq len (- len seg))
                   (setq lst (cons (vlax-curve-getPointAtDist (nth counter poly) len) lst))
                );end repeat
			  );end progn else
			  );end if
			);end progn else
           );end if
      )
      ((eq (vla-get-Objectname (nth counter poly)) "AcDbLine")
           (setq lst (cons (vlax-get (nth counter poly) 'StartPoint) lst))
      )
    )
	(Setq counter (+ counter 1))
  )
  
  (foreach obj poly
    (vla-delete obj)
   )
   
  (Set_osmode t)
  (setq SS1 (ssget "_WP" lst))
  ;(setq SS2 (ssget "_CP" lst)) ;used for testing if anything is crossing
)


;;;;;;;;Required Subfunctions to run (SELECTINSIDE)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun asin (x) ;;;Arc Sin function
(cond
((equal x 1.0 1.0e-16)
(* pi 0.5)
)
((equal x -1.0 1.0e-16)
(* pi -0.5)
)
((< (abs x) 1.0)
(atan (/ x (sqrt (- 1.0 (* x x)))))
)
(T
(prompt "\n*ERROR* (abs x) > 1.0 from ASIN function\n")
)
)
)

(defun RtD (r) (* 180.0 (/ r pi))) ;;;converts radians to degrees

(defun ceil (x / n) ;;;;;Rounds 'x' up to the nearest intiger
  (if (or (= (setq n (fix x)) x) (< x 0))
    n
    (1+ n)
  )
)

(defun LM:roundm ( n m ) ;;;;;Rounds 'n' to the nearest multiple of 'm' 
    (* m (atoi (rtos (/ n (float m)) 2 0)))
)

(defun Set_osmode (flg) ; nil=OFF  t=ON
   (if (or (and flg (>= (getvar "osmode") 16383)) ; ON & osmode is off
           (and (null flg) (<= (getvar "osmode") 16383)) ; OFF & osmode is ON
       )
     (setvar "osmode" (boole 6 (getvar "osmode") 16384)) ; Toggle osmode
   )
 )


;;;;;;;;Test Subfunctions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun c:test ( / e )  ;;;;;used to test what the selection set is actually selecting
   (if
       (and
           (setq e (car (entsel)))
           (member (cdr (assoc 0 (entget e))) '("CIRCLE" "ELLIPSE" "SPLINE" "LWPOLYLINE" "POLYLINE"))
       )
       (sssetfirst nil (selectinside e)) 
   )
   (princ)
)
(vl-load-com) (princ)

(defun Drawlst () ;;;;;used to see what the list for the selection set looks like
(Set_osmode nil)
(command "pline")
(foreach n lst
(command n)
);;end foreach
(command "")
(Set_osmode t)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


 

Edited by Sambo
  • Like 1
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...