Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/23/2023 in all areas

  1. Again as Before UCS W PLAN Move the text to inside the cupboard.
    1 point
  2. Yeah don't know what pnt was for either just left it in. But for setpropertyvalue its a Autocad Function that sets values of an entity. you can feed it enames as well with out having to convert over to vla-objects. You can also use getpropertyvalue to pull things like attributes strings from blocks. with just one line of code.
    1 point
  3. Consider something like the following: (while (not (or (= "" (setq nodwg (getstring "\nEnter the number <exit>: "))) (wcmatch nodwg "###") ) ) (princ "\nNumber must be in the range 001-999.") ) (if (/= "" nodwg) (progn ;; do stuff ) )
    1 point
  4. ; DentRepair - 2023.09.15 exceeds ; Dent repairs polyline segments with vertical and horizontal outlines outwards. ; If the length of one line segment is less than a certain value, it adjusted out to a wider side. (defun c:DentRepair ( / *error* acdoc ss ssl index ent obj clist cllen isclosed index2 p0 p1 p2 p3 linelength lineangle setlength tempclist1 tempclist2 temp1 temp2 temp1obj temp2obj temp1area temp2area stopper resultent ) (vl-load-com) (defun *error* (msg) (if (/= msg "Function cancelled") (princ (strcat "\nError: " msg)) ) (vla-EndUndoMark acdoc) (princ) ) ;; Group by Number - Lee Mac ;; Groups a list 'l' into a list of lists, each of max length 'n' (defun LM:group<n ( l n ) (if l (LM:group<n-sub (cons nil l) n n)) ) (defun LM:group<n-sub ( l m n ) (if (and (cdr l) (< 0 n)) (LM:group<n-sub (cons (cons (cadr l) (car l)) (cddr l)) m (1- n)) (cons (reverse (car l)) (LM:group<n (cdr l) m)) ) ) ;;---------------------=={ Subst Nth }==----------------------;; ;; ;; ;; Substitutes an item at the nth position in a list. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; a - item to substitute ;; ;; n - position in list to make the substitution ;; ;; l - list in which to make the substitution ;; ;;------------------------------------------------------------;; ;; Returns: Resultant list following the substitution ;; ;;------------------------------------------------------------;; (defun LM:SubstNth ( a n l ) (if l (if (zerop n) (cons a (cdr l)) (cons (car l) (LM:SubstNth a (1- n) (cdr l))) ) ) ) ;; Unique - Lee Mac ;; Returns a list with duplicate elements removed. (defun LM:Unique ( l ) (if l (cons (car l) (LM:Unique (vl-remove (car l) (cdr l))))) ) ; degree to radian (defun dtr (a) (setq x (* pi (/ a 180.0))) ) ; radian to degree (defun rtd (a) (setq x (/ (* a 180) pi)) ) (defun lwpolybylist (lst cls) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 cls) ) (mapcar (function (lambda (p) (cons 10 p))) lst) ) ) ) (setq acdoc (vla-get-ActiveDocument (vlax-get-ACAD-Object))) (vla-StartUndoMark acdoc) (setq setlength (getreal "\n Input Minimum Segment Value (Space Bar = 1.5): ")) ; can edit this value (if (= setlength nil) (setq setlength 1.5) (setq setlength (abs setlength)) ) (setq ss (ssget '((0 . "LWPOLYLINE")))) (setq ssl (sslength ss)) (setq index 0) (repeat ssl (setq ent (ssname ss index)) (setq obj (vlax-ename->vla-object ent)) (setq clist (vlax-safearray->list (vlax-variant-value (vlax-get-property obj 'coordinates)))) (setq cllen (length clist)) (setq isclosed (vlax-get-property obj 'closed)) ;(princ "\n isclosed? ") ;(princ isclosed) (if (= isclosed :vlax-true) (progn (setq clist (append clist (list (car clist) (cadr clist)))) ) (progn (if (and (= (car clist) (nth (- cllen 2) clist)) (= (cadr clist) (nth (- cllen 1) clist))) (progn) (progn (setq clist (append clist (list (car clist) (cadr clist)))) ) ) ) ) (setq clist (lm:unique (lm:group<n clist 2))) ;(princ "\n clist - ") ;(princ clist) (setq cllen (length clist)) (setq index2 0) (if (>= cllen 4) (progn (repeat cllen (if (and (/= index2 0) (/= resultent nil)) (entdel resultent) ) (setq p1 (nth index2 clist)) (if (= (- cllen 1) index2) (setq p2 (nth 0 clist)) (setq p2 (nth (+ index2 1) clist)) ) (if (= index2 0) (setq p0 (last clist)) (setq p0 (nth (- index2 1) clist)) ) (if (<= index2 (- cllen 3)) (setq p3 (nth (+ index2 2) clist)) (setq p3 (nth (- (+ index2 2) cllen) clist)) ) (setq linelength (distance p1 p2)) ;(princ "\n linelength - ") ;(princ linelength) (setq lineangle (rtd (angle p1 p2))) ;(princ "\n lineangle - ") ;(princ lineangle) (setq tempclist1 '()) (setq tempclist2 '()) (if (>= linelength setlength) (progn ;(if (or (= lineangle 0) (= lineangle 90) (= lineangle 180) (= lineangle 270) (= lineangle 360)) ; (progn) ; (progn) ;) ) (progn (cond ((or (= (rtos lineangle 2 0) "0") (= (rtos lineangle 2 0) "180")) ;horizontal line (setq tempclist1 (LM:SubstNth (list (car p1) (cadr p0)) index2 clist)) (setq tempclist1 (LM:SubstNth (list (car p2) (cadr p0)) (if (= (- cllen 1) index) 0 (+ index2 1)) tempclist1)) (setq tempclist2 (LM:SubstNth (list (car p1) (cadr p3)) index2 clist)) (setq tempclist2 (LM:SubstNth (list (car p2) (cadr p3)) (if (= (- cllen 1) index) 0 (+ index2 1)) tempclist2)) ) ((or (= (rtos lineangle 2 0) "90") (= (rtos lineangle 2 0) "270") (= (rtos lineangle 2 0) "360")) ;verical line (setq tempclist1 (LM:SubstNth (list (car p0) (cadr p1)) index2 clist)) (setq tempclist1 (LM:SubstNth (list (car p0) (cadr p2)) (if (= (- cllen 1) index) 0 (+ index2 1)) tempclist1)) (setq tempclist2 (LM:SubstNth (list (car p3) (cadr p1)) index2 clist)) (setq tempclist2 (LM:SubstNth (list (car p3) (cadr p2)) (if (= (- cllen 1) index) 0 (+ index2 1)) tempclist2)) ) (t (setq tempclist1 clist) (setq tempclist2 clist) ) ) ;(princ "\n tempclist1 - ") ;(princ tempclist1) (setq temp1 (lwpolybylist tempclist1 1)) ;(princ "\n tempclist2 - ") ;(princ tempclist2) (setq temp2 (lwpolybylist tempclist2 1)) (setq temp1obj (vlax-ename->vla-object temp1)) (setq temp2obj (vlax-ename->vla-object temp2)) (setq temp1area (vla-get-area temp1obj)) (setq temp2area (vla-get-area temp2obj)) (if (>= temp1area temp2area) (setq clist tempclist1) (setq clist tempclist2) ) (entdel temp1) (entdel temp2) ) ) (setq resultent (lwpolybylist clist 1)) ;(setq stopper (getstring "\n continue ? : ")) ;(princ "\n index2 - ") ;(princ index2) ;(princ " / cllen - ") ;(princ cllen) (setq index2 (+ index2 1)) ) ) (progn (princ "\n not enough vertices. (less then 4)") ) ) ;(setq stopper (getstring "\n continue ? : ")) (setq index (+ index 1)) ) (vla-EndUndoMark acdoc) (princ) ) You can start with this. command : DENTREPAIR Below GIF is for example (with pauses to show the calculation step by step) + This isn't a perfect solution. The steps in this routine are... 1. Measure the length of each line segment of the polyline. 2. If it is less than the set value (=1.5), 3. determine whether the line segment is vertical or horizontal, 4. Get the X (for a vertical line) or Y (for a horizontal line) value of both nodes adjacent to the line segment. 5. Replace the values in the original coordinate list 6. After creating each polyline, Compare each area and select the larger one. 7. Repeat this by looping each line segment. It is useful when there is a large fixed outline with small cracks, but the leakage point of this logic is if it is sharp, that part can be omitted. -> sharp means If there is a line segment that protrudes to the outermost edge with a value smaller than the entered value of 1.5 This is because the two neighboring points of this sharp point are located in a direction where the area is smaller than the original outline. In that case, the original point should be included in the comparison to find the one with the largest area among the 3 cases. If the original wins, this case is difficult, picked line segment is not modified, but both neighboring points need to be modified. It is difficult to solve this problem by simply running a forward loop. Even after modifying the neighboring points on both sides, need to check whether the rules are correct retrieve the coordinate list again, and the node numbers may also be messed up. Of course, this may be difficult only for me. Because there are many smart people. so I created a routine to create a new line above it. not modifying original line. It would be better to check manually.
    1 point
  5. Before writing a routine, you must check that the conditions are logically flawless. From the length between polyline nodes, we need to distinguish between lines to be taken and lines not to be taken. Once the loop is run once, these two white lines in the example must survive. Since the rule is not grid snap 1.5 because the result's nodes do not fall to 1.5, deleting the right line must be done by looping once more with the result of the first loop. The left white line will survive though. Since the general routine makes judgments by comparing the front and back points, a new routine may be needed to estimate the edges using extension lines at the nodes at both ends. Extract the coordinates of each point of the polyline, first extract the cases where both sides are 1.5 or more from the length of the line segment (points marked with a 1.5 radius circle), and then draw only one side. After marking the point (marked by x) that is greater than 1.5, then draw a line first when there are continuous circles, draw directly towards the next point x on the circle. Now, we need to find the included angle in all coordinates other than 0 90 180 270 and remove that node. You also need to decide which side of the line to align it with. This is the guessing based on only the nodes, but if there is a condition that the area should not be modified in a way that makes it smaller, your example can be valid. In this case, you must add a routine to determine the area of the closed area and a routine to determine whether a point is inside or outside the closed polyline. It will become more complicated than guessing based on just the nodes.
    1 point
×
×
  • Create New...