Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/20/2026 in all areas

  1. [XDrX-PlugIn(160)] extend or cut curve with circle (theswamp.org) https://www.theswamp.org/index.php?topic=59528.0 Implemented using moving grips(stretch point) (defun c:xdtb_cirextend (/ box clone ints nearpt pnt r ss ss1 strepnts x y z) (xd::doc:getdouble (xdrx-string-multilanguage "\n圆半径" "\nCircle Radius") "#mradius" 10.0 ) (if (setq ss (xdrx-ssget (xdrx-string-multilanguage "\n选择圆<退出>:" "\nSelect Circle<Exit>:") '((0 . "circle")) ) ) (progn (mapcar '(lambda (x) (setq r (xdrx-getpropertyvalue x "radius") box (xdrx-entity-box x) box (xd::pnts:close box) ) (setq clone (xdrx-object-clone x)) (xdrx-setpropertyvalue x "radius" #mradius) (if (setq ss1 (ssget "f" box '((0 . "*polyline,line")))) (progn (mapcar '(lambda (y) (setq strepnts (xdrx-entity-getstretchpoint y)) (if (setq pnt (vl-some '(lambda (z) (if (xdrx-point-ison z clone) z ) ) strepnts ) ) (progn (if (setq ints (xdrx-entity-intersectwith y x 1)) (progn (setq nearpt (xdrx-points-nearpt pnt ints)) (xdrx-entity-movestretchpointex y pnt (mapcar '- nearpt pnt ) ) ) ) ) ) ) (xdrx-ss->ents ss1) ) ) ) (xdrx-entity-delete clone) ) (xdrx-ss->ents ss) ) ) ) (princ) ) ===================================== The above code uses XDrx API, download link: https://github.com/xdcad/XDrx-API-zip https://sourceforge.net/projects/xdrx-api-zip/ Dual version link: https://github.com/xdcad
    1 point
  2. Sure. Replace this function. I didn't touch the rest ;; WAMP for Write Area in the Middle of Polyline (defun c:wamp ( / pline ss i hgt clay lay) ;; current layer (setq clay (getvar "CLAYER")) ;; User setting. Set to your liking (setq hgt 2.5) ;; user selects polylines (princ "\nSelect polylines: ") (setq ss (ssget (list (cons 0 "*POLYLINE")))) ;; loop of the elements (setq i 0) (repeat (sslength ss) (setq pline (ssname ss i)) ;; set layer of polyline to current (setvar "CLAYER" (setq lay (cdr (assoc 8 (entget pline)))) ) (wamp pline hgt) (setq i (+ i 1)) ) (setvar "CLAYER" clay) )
    1 point
  3. I have this with field It work's with entities selection or boundarie (vl-load-com) (defun c:surf_curve-closed ( / AcDoc Space loop js pt_in new_pl area_obj nw_obj ename ent_text dxf_ent key) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace AcDoc) (vla-get-ModelSpace AcDoc) ) loop T ) (princ "\nSelect a closed object or <Enter/Right-click> for a point in interior of area") (while loop (setq js (ssget "_+.:E:S" '( (-4 . "<OR") (-4 . "<AND") (0 . "*POLYLINE") (-4 . "<AND") (-4 . "<NOT") (-4 . "&") (70 . 120) (-4 . "NOT>") (-4 . "&") (70 . 1) (-4 . "AND>") (-4 . "AND>") (0 . "CIRCLE") (-4 . "<AND") (0 . "SPLINE") (-4 . "&") (70 . 1) (-4 . "AND>") (-4 . "<AND") (0 . "ELLIPSE") (41 . 0.0) (42 . 6.283185307179586) (-4 . "AND>") (-4 . "OR>") ) ) area_obj nil ) (cond ((null js) (setq pt_in (getpoint "\nGive interior point or <Enter/Right-click> for quit?: ") new_pl (bpoly pt_in nil '(0 0 1)) ) (if (eq (type new_pl) 'ENAME) (setq area_obj (vlax-get-property (setq ename (vlax-ename->vla-object new_pl)) "Area")) (setq loop nil) ) ) (T (setq area_obj (vlax-get-property (setq ename (vlax-ename->vla-object (ssname js 0))) "Area")) ) ) (cond (area_obj (if (zerop (getvar "USERR1")) (setvar "USERR1" (/ (getvar "VIEWSIZE") 75.0))) (setq nw_obj (vla-addMtext Space (vlax-3d-point (trans (getvar "VIEWCTR") 1 0)) 0.0 (strcat "{\\fArial|b0|i0|c0|p34;" "%<\\AcObjProp.16.2 Object(%<\\_ObjId " (itoa (vla-get-ObjectID ename)) ">%).Area \\f \"%lu2%pr3\">%" ) ) ) (mapcar '(lambda (pr val) (vlax-put nw_obj pr val) ) (list 'AttachmentPoint 'Height 'DrawingDirection 'StyleName 'Layer 'Rotation 'BackgroundFill 'Color) (list 1 (getvar "USERR1") 5 (getvar "TEXTSTYLE") (getvar "CLAYER") 0.0 -1 256) ) (setq ent_text (entlast) dxf_ent (entget ent_text) dxf_ent (subst (cons 90 1) (assoc 90 dxf_ent) dxf_ent) dxf_ent (subst (cons 63 255) (assoc 63 dxf_ent) dxf_ent) ) (entmod dxf_ent) (while (and (setq key (grread T 4 0)) (/= (car key) 3)) (cond ((eq (car key) 5) (setq dxf_ent (subst (cons 10 (trans (cadr key) 1 0)) (assoc 10 dxf_ent) dxf_ent)) (entmod dxf_ent) ) ) ) (vlax-put (vlax-ename->vla-object (entlast)) 'TextString (strcat "{\\fArial|b0|i0|c0|p34;" "%<\\AcObjProp.16.2 Object(%<\\_ObjId " (itoa (vla-get-ObjectID ename)) ">%).Area \\f \"%lu2%pr3\">%" ) ) ) (T (setq loop nil)) ) (princ "\nSelect a closed object or <Enter/Right-click> for a point in interior of area") ) (prin1) )
    1 point
  4. I started from scratch. Is this how you want is? Bottom function: adapt the text height to your likings . Now: (setq hgt 2.5) ;;1. promt the user to select multiple polygons. ;;2. in a loop: ;; a. calculate each polygon area. ;; b. insert the area text in the geometric center of each polygon (vl-load-com) ;; Multiple assoc. Returns a list of all requested (assoc) with set key ; use like this (massoc 10 YourListOfData) (defun massoc (key alist / x nlist) (foreach x alist (if (eq key (car x)) (setq nlist (cons (cdr x) nlist)) ) ) (reverse nlist) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; https://www.cadtutor.net/forum/topic/18257-entmake-functions/ (defun drawText (pt hgt str) (entmakex (list (cons 0 "TEXT") (cons 10 pt) (cons 40 hgt) (cons 1 str)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; main function (defun wamp (pline hgt / area pt str vert_pts x y p) (setq area (vla-get-area (vlax-ename->vla-object pline) )) ;; get the vertex positions. (setq vert_pts (massoc 10 (entget pline))) (setq x 0.0) (setq y 0.0) ;; Then calculate the average. Sum of x and y values divided by the number of vertices (foreach p vert_pts (setq x (+ x (nth 0 p))) (setq y (+ y (nth 1 p))) ) (setq pt (list (/ x (length vert_pts)) (/ y (length vert_pts)) )) ;; make a string out of the area float. Here would be the place to add a prefix or postfix. Example: ;; (setq str (strcat "area: " (rtos area 2 3) )) (setq str (rtos area 2 3)) ;; that 3 means 3 decimals. Feel free to change this (drawText pt hgt str) (princ ) ) ;; WAMP for Write Area in the Middle of Polyline (defun c:wamp ( / pline ss i hgt) ;; User setting. Set to your liking (setq hgt 2.5) ;; user selects polylines (princ "\nSelect polylines: ") (setq ss (ssget (list (cons 0 "*POLYLINE")))) ;; loop of the elements (setq i 0) (repeat (sslength ss) (setq pline (ssname ss i)) (wamp pline hgt) (setq i (+ i 1)) ) )
    1 point
×
×
  • Create New...