Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/06/2024 in all areas

  1. Use DATE instead of CDATE: https://help.autodesk.com/view/ACD/2023/ENU/?guid=GUID-CBB24068-1654-4753-BE2E-1D0CE9700411 DATE stores the date value as a Julian date, which simply counts the number of days which have elapsed from a given epoch - as such, you can easily subtract two integer Julian date values to calculate the number of elapsed days between two dates, e.g.: (< 7 (- (getvar 'date) (atoi (getenv "TELNUMBERS")))) (assuming you have changed TELNUMBERS to store the DATE value instead of CDATE)
    2 points
  2. Oh, I see now. There's a function that replaces the list of coordinates (vlax-put (vlax-ename->vla-object ent) 'coordinates coords) So I read the coordinates, set the most North one to 0, then replace the coordinates. Like this: Command MFV for Modify First Vertex (vl-load-com) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; LW Vertices - Lee Mac ;; Returns a list of lists in which each sublist describes ;; the position, starting width, ending width and bulge of the ;; vertex of a supplied LWPolyline (defun LM:LWVertices ( e ) (if (setq e (member (assoc 10 e) e)) (cons (list (assoc 10 e) (assoc 40 e) (assoc 41 e) (assoc 42 e) ) (LM:LWVertices (cdr e)) ) ) ) (defun getVertices ( pline / verts vert res) (setq verts (LM:LWVertices (entget pline) )) (setq res (list)) (foreach vert verts (setq p (cdr (assoc 10 vert))) (setq res (append res (list p))) ) res ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; returns the index of the vertex with the max Y value (defun getMaxYVert ( verts / maxY i ind) (setq maxY nil) (setq ind 0) (setq i 0) (foreach a verts (if (= nil maxY) (setq maxY (nth 1 a)) (if (> (nth 1 a) maxY) (progn (setq ind i) (setq maxY (nth 1 a)) ) ) ) (setq i (+ i 1)) ) ind ) ;; MFV for Modify First Vertex (defun c:MFV ( / ss i j ent verts maxYindex verts2 coords) (setq ss (ssget (list (cons 0 "*POLYLINE") (cons 70 1)))) (setq i 0) (repeat (sslength ss) ;;(princ "\n") (setq ent (ssname ss i)) (setq verts (getVertices ent)) (setq maxYindex (getMaxYVert verts)) (setq coords (list)) ;; new list of coordinates. (list x0 y0 x1 y1 x2 y2...), rearraned to have the most North one first (setq j 0) (princ maxYindex) (repeat (length verts) (setq coords (append coords (list (nth 0 (nth (rem (+ j maxYindex) (length verts)) verts)) (nth 1 (nth (rem (+ j maxYindex) (length verts)) verts)) ))) (setq j (+ j 1)) ) ;; now replace the verices verts by coords (vlax-put (vlax-ename->vla-object ent) 'coordinates coords) ;;(princ coords) (setq i (+ i 1)) ) (princ) )
    1 point
  3. Can you better explain wat must happen? Maybe upload a dwg example?
    1 point
  4. Nikon look at my example. yes need to (vlax-get obj 'Textstring) (setq obj (vlax-ename->vla-object (car (entsel "Pick mtext ")))) (setq txt (vlax-get obj 'textstring)) (vlax-put obj 'Textstring (strcat (chr 92) (chr 123) txt (chr 92) (chr 125))) Ok use (ascii (getstring)) to find the ascii character code, 92=\ an odd one is {=123 and }=125, 124 is something else.
    1 point
  5. @enthralled It absolutely helps. Thanks. PLZ is an odd name for this function, but it does exactly what I need, including what I didn't mention. That is: It removes all consecutive duplicate vertices, including the last one, if it's the same as the first one. If the first and last vertices are the same, and if the polyline is not closed, it marks it as closed. It does not mark the polyline as closed in any other circumstance. I'm writing this down for anyone who might want to understand the function without testing it (me in the future, hi there)
    1 point
  6. Why did you remove the author name from the codes ?
    1 point
  7. Just checked and the ideas work on my computer and CAD which is odd. (defun c:HPO (/ lst) (setq lst '(("*outdoor*" "HPO-Outdoor") ("*building*" "HPO-Building") ("*setout*,*offset*" "HPO-Setout") ("bdy-stage*,bdy-design*,bdy,dp*,cp*,*stage*" "Bdy") ) ) (foreach e lst (mergelayers (car e) (cadr e))) (princ) ) (defun mergelayers (match to / lst def lay) (setq str "") (or (tblsearch "LAYER" to) (command "_.LAYER" "_N" to "") ) (while (setq def (tblnext "LAYER" (null lay))) (if (and (wcmatch (strcase (setq lay (cdr (assoc 2 def)))) (strcase match) ) (not (wcmatch (strcase lay) (strcat "*|*,0,DEFPOINTS," (strcase to)) ) ) ) (setq lst (cons lay lst)) ) ) (if lst (progn (command "_.LAYMRG") (foreach e lst (command "_Name" e)) (command "" "_N" to "_Y") ) ) (setq sel2 (ssget "_X" '((-4 . "<or") (8 . "*-HPO*") (8 . "*Survey*") (8 . "*Wall*") (8 . "*U-*") (8 . "*SCIMS*") (8 . "Bdy-Tie") (8 . "*Traverse*") (8 . "*Fence*") (8 . "*Road*") (8 . "*Check*") (8 . "*Chk*") (-4 . "or>") ) ) ) (sssetfirst nil sel2) (if (= sel2 nil) () ; if sel2 is a 'nil' selection, do nothing (command "_erase" sel2 "") ; if sel2 is a selection, then erase it ) )
    1 point
  8. My take (defun c:testline ( / item fileName fn exlintyp ) (vl-load-com) (setq fileName "D:\\MyLineTypeTextFile.txt") (setq lines (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object)))) (princ (strcat "\nTotal of " (itoa (vla-get-count lines)) " Line Type(s) ... " )) (setq fn (open fileName "w")) (vlax-for LT lines (princ (strcat "\n"(vla-get-Name LT ))) (setq exlintyp (vla-get-Name LT)) (write-line exlintyp fn) ) (close fn) (princ) ) (c:testline) Another similar task just did this for a particular problem. ; draw all linetypes as a look at ; By AlanH Oct 2021 (setq pt (getpoint "\nPick a point for linetypes")) (setq lts (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object)))) (setq lst '()) (vlax-for ltname lts (setq ltn (vla-get-name ltname)) (princ (strcat "\n" ltn)) (if (or (= ltn "ByBlock")(= ltn "ByLayer")) (princ "ByBlock or Bylayer") (setq lst (cons ltn lst)) ) ) (setq lst (vl-sort lst '<)) (foreach lt lst (setq pt2 (mapcar '+ pt (list 60.0 0.0 0.0))) (command "Line" pt pt2 "") (vla-put-linetype (vlax-ename->vla-object (entlast)) lt) (setq pt2 (mapcar '+ pt (list 75.0 0.0 0.0))) (command "text" pt2 3.5 0.0 lt) (setq pt (mapcar '+ pt (list 0.0 -10.0 0.0))) )
    1 point
  9. Help to correct below route ! I wanted to have all line types as text file (defun c:testline ( / item fileName fn exlintyp ) (vl-load-com) (setq fileName "D:\\MyLineTypeTextFile.txt") (vlax-for item (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object))) (princ (strcat "\n"(vla-get-Name item )))) (princ (strcat "\nTotal of " (itoa (sslength item )) " Line Type(s) ... " )) (progn (setq fn (open fileName "w")) (setq exlintyp (vla-get-Name item)) (textscr) (write-line exlintyp fn) (close fn)) (princ))
    1 point
×
×
  • Create New...