Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/15/2025 in all areas

  1. I never wrote this app with dynamic blocks in the back in my mind but I may have a look at this someday. Thing is , I have very few dynamic blocks myself. Probably can count them on one hand. Mainly because static block are easier to handle in lisp. (very difficult to teach old dragons new tricks haha)
    2 points
  2. This function is multipurpose. You need to accompany it with two arguments: 'lw' is the entity name of the polyline you want to check 'p' can be: a list of points; the entity name of a "TEXT", "MTEXT", "POINT", "SHAPE", or "INSERT" that you want to check if it's within the polyline; or a text string, in which case it will be used as a filter to create a selection set of texts containing that string, and all of which will be checked if they are included in the lwpolyline. In all cases, the function returns, depending on what was entered as the second argument, a list with the point and/or the objects included in the lwpolyline, or nil if none exist.
    1 point
  3. @maahee Ray-Casting trauma has hit me I forgot your interest was the opposite: checking the point from the lwpolyline I'll fix that right now. ;*************************************** ;****** G L A V C V S F E C I T ****** ; ARGUMENTS: ; lw -> LWPOLYLINE entity name ; p -> can be: -list point ; -TEXT, MTEXT, SHAPE, POINT or INSERT entity name ; -text string (string for make a text selection set by string filter) ; ; Return: list with object/s or list point inside the polyline; or nil (defun inside? (lw p / en ex d r rs l i n o r4 cj) (defun r4 (p e / r is f l) (foreach l '(0 1.5708 3.141592 4.71239) (if (not f) (progn (setq r (vla-addline i (vlax-3d-point p) (vlax-3d-point (polar p l d)))) (if (setq is (safearray-value (variant-value (vla-intersectWith r e 0)))) (setq f (= (rem (length is) 2) 0)) (setq f T) ) (vla-delete r) ) ) ) (not f) ) (setq en (getvar "extmin") ex (getvar "extmax") d (max (- (car ex) (car en)) (- (cadr ex) (cadr en))) i (vlax-ename->vla-object (cdr (assoc 330 (entget lw)))) ) (cond ((= (type p) 'LIST) (if (r4 p (vlax-ename->vla-object lw)) (list p) ) ) ((= (type p) 'ENAME) (if (wcmatch (cdr (assoc 0 (setq l (entget p)))) "*TEXT,SHAPE,POINT,INSERT") (if (r4 (cdr (assoc 10 l)) (vlax-ename->vla-object lw)) (list p) ) ) ) ((= (type p) 'STR) (if (setq cj (ssget "x" (list '(0 . "TEXT") (cons 1 p)))) (if (setq cj (vl-remove-if 'listp (mapcar 'cadr (ssnamex cj)))) (foreach o cj (if (r4 (cdr (assoc 10 (entget o))) (vlax-ename->vla-object lw)) (setq rs (cons o rs)) ) ) ) ) rs ) ) )
    1 point
  4. Do a google "dynamic block to static block autocad" 1st result was an answer.
    1 point
  5. Solving this involves letting the algorithm analyze the rest of the set and implementing a little more code to filter the results. For this reason, I decided to emphasize my initial approach. Forgive me if I'm a bit long-winded in my explanation, but I believe that for those of us who work in the world of cartography, topography and geographic information systems, these resources are of interest. Therefore, I attach below the results of my approach, which are as follows: - Create a selection set, as limited as possible, of closed polylines that will need to be fully analyzed - Analyze all the perimeters and store those that enclose the reference point - Select and return the one with the smallest area The result, given the limited scope of the analysis (closed polylines), has allowed the required code to be considerably less than expected. Below is the code: ;*************************************** ;****** G L A V C V S F E C I T ****** (defun selR (p / r s l lt en ex d cj i n o r4 f) (defun r4 (p e / r is f) (foreach l '(1.5708 3.141592 4.71239) (setq r (vla-addline i (vlax-3d-point p) (vlax-3d-point (polar p l d)))) (if (setq is (safearray-value (variant-value (vla-intersectWith r e acextendnone)))) (setq f (cons (= (rem (length is) 2) 1) f)) ) (vla-delete r) ) f ) (setq en (getvar "extmin") ex (getvar "extmax") n -1 d (max (- (car ex) (car en)) (- (cadr ex) (cadr en))) ) (if (setq cj (ssget"_X" (list '(0 . "LWP*") '(-4 . "&=") '(70 . 1) (cons 410 (if (= 1 (getvar 'cvport)) (getvar 'ctab) "Model")) '(-4 . "<and") '(-4 . ">,>,*") (list 10 (car p) (- (cadr p) 50.0) 0.0) '(-4 . ">,<,*") (list 10 (car p) (+ (cadr p) 50.0) 0.0) '(-4 . "and>") ) ) ) (while (setq e (ssname cj (setq n (1+ n)))) (setq lt nil) (if (not r) (setq r (vla-addline (setq i (vlax-ename->vla-object (cdr (assoc 330 (entget e))))) (vlax-3d-point p) (vlax-3d-point (polar p 0 d)))) ) (if (setq l (safearray-value (variant-value (vla-intersectWith r (setq o (vlax-ename->vla-object e)) acextendnone)))) (if (= (rem (length (setq l (while l (setq lt (cons (list (nth 0 l) (nth 1 l) (nth 2 l)) lt) l (cdddr l) lt lt)))) 2) 1) (if (and (car (setq f (r4 p o))) (cadr f) (caddr f)) (setq s (if s (if (< (vla-get-area o) (vla-get-area s)) o) o)) ) ) ) ) ) (if r (vla-delete r)) (if s (sssetfirst nil (ssadd (vlax-vla-object->ename s)))) s )
    1 point
  6. Hi I was about to give up completely on the idea of finding intersections with 'RAY' objects on a general set. But at the last minute, I discovered something in @Lee Mac's code that changed my mind: it selects the first perimeter that encloses the reference point and discards the rest. rayF-ezgif.com-gif-to-mp4-converter.mp4
    1 point
×
×
  • Create New...