Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/09/2019 in all areas

  1. Grr (INCHES->FEETNINCHES 56.125) >> (4 FT 8.125) No its 4' 8 1/8 "
    1 point
  2. 1 point
  3. I agree with you Bigal , why not use blocks or layouts. But maybe user has some historical baggage I dunno... But if OP has to use polylines I would recommend putting them in a special layer so selecting them would be easier by including layer name in selection filter. anyways , another code that also sorts the polylines (untested of course since we have no sample to test it on) (defun c:t4 ( / a sp i ss to p) (setq a (vla-get-activedocument (vlax-get-acad-object)) sp (vla-get-block (vla-get-activelayout a)) i 0) (prompt "\nSelect polylines to number :") (if (setq ss (ssget ":L" '((0 . "LWPOLYLINE")))) (foreach p (vl-sort (mapcar '(lambda (x) (GetBcent x)) (setq ss (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))) '(lambda (a b)(if (equal (cadr a) (cadr b) 1e-8) (< (car a) (car b)) (> (cadr a) (cadr b))))) (setq to (vla-AddText sp (itoa (setq i (1+ i))) (vlax-3d-point p) (/ (getvar 'viewsize) 50))) (vla-put-Alignment to acAlignmentRight)(vla-put-textalignmentpoint to (vlax-3d-point p))(vla-put-Alignment to acAlignmentMiddle) ) ) (vla-Regen a acActiveViewport) (princ) ) ; get boundingbox center (defun GetBcent ( %e / ll ur) (if (= (type %e) 'ENAME)(setq %e (vlax-ename->vla-object %e))) (cond ; get the centerpoint from boundingbox ((and (vlax-method-applicable-p %e 'getboundingbox) (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list %e 'll 'ur))))) (mapcar (function (lambda (a b) (/ (+ a b) 2.)))(vlax-safearray->list ll)(vlax-safearray->list ur))) ; else get alignment or point ((and (vlax-method-applicable-p %e 'alignment)(= (vla-get-alignment %e) 1)) (reverse (cdr (reverse (vlax-safearray->list (vlax-variant-value (vla-get-TextAlignmentPoint %e))))))) (t (reverse (cdr (reverse (vlax-safearray->list (vlax-variant-value (vla-get-InsertionPoint %e))))))) ) )
    1 point
  4. What software are you working in? There is no "Project Manager" in AutoCAD.
    1 point
  5. must admit I have a little difficulty to understand what it is exactly that OP wants , place a text in the center of a poly or find one... ; place a string in center of (all) poly's (defun c:t1 ( / a sp ss i ts o l r pt to) (setq a (vla-get-activedocument (vlax-get-acad-object)) sp (vla-get-block (vla-get-activelayout a))) (prompt "\nSelect polylines to number :") (if (setq ss (ssget)) (progn (setq i 0 ts (/ (getvar 'viewsize) 50) ss (vla-get-activeselectionset a)) (vlax-for o ss (if (= (vlax-get-property o 'ObjectName) "AcDbPolyline") (progn (vla-getboundingbox o 'l 'r) (setq pt (mapcar '/ (mapcar '+ (vlax-safearray->list l) (vlax-safearray->list r)) '(2 2 2))) (setq to (vla-AddText sp (itoa (setq i (1+ i))) (vlax-3d-point pt) ts)) (vla-put-Alignment to acAlignmentRight) (vla-put-textalignmentpoint to (vlax-3d-point pt)) (vla-put-Alignment to acAlignmentMiddle) ) ) ) ) ) (vla-Regen a acActiveViewport) (princ) ) ; finding a string in center of (all) poly's (defun c:t2 ( / ss o l r sel lst) (if (setq ss (ssget "x" '((0 . "LWPOLYLINE")))) (vlax-for o (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))) (vla-getboundingbox o 'r 'l) (if (setq sel (ssget "w" (setq r (vlax-safearray->list r)) (setq l (vlax-safearray->list l)) '((0 . "TEXT")))) (setq lst (cons (cons (cdr (assoc 1 (entget (ssname sel 0)))) (list l r)) lst))))) (if (and (vl-consp lst) (setq plt (getstring "\nEnter plot number : ")) (assoc plt lst)) (prompt (strcat "\nPlot number " plt " : " (vl-princ-to-string (cdr (assoc plt lst))))) (prompt "\nNo plotnumber found or selected") ) (princ) ) (vl-load-com)
    1 point
×
×
  • Create New...