Leaderboard
Popular Content
Showing content with the highest reputation on 06/27/2022 in all areas
-
This will convert any dim that has text overridden with distof. --edit updated code to store the old override (undo command?) in the suffix also adds text above the dim of the old dimoverride Note this command should be a temp fix --edit didn't account for dims at different angles. (defun C:DIM-Convert (/ ss dim obj old dist off hgt pt) (if (setq ss (ssget '((0 . "DIMENSION")))) (foreach dim (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (setq obj (vlax-ename->vla-object dim)) (if (eq (setq old (vlax-get obj 'TextOverride)) "") (progn) (progn (setq dist (distof old)) (vla-put-textoverride obj dist) (vla-put-textsuffix obj old) ;store old overide ;(setq off (* (setq hgt (vlax-get obj 'TextHeight)) 1.5)) ;(setq pt (vlax-get obj 'TextPosition)) ;(setq pt (list (car pt) (+ (cadr pt) off))) ;(entmake (list '(0 . "TEXT")(cons 10 pt)(cons 11 pt)(cons 40 hgt)(cons 1 old)'(072 . 4))) ) ) ) ) (princ) )1 point
-
Distof will take a string, typically assumed to be a length, and convert it to a decimal number (you can set it to do decimals, fractions, etc). So you can have some code that goes through each mtext object, rip the number from it (which will be in the form of a string) and apply distof to it. Then if you want to convert it back to a string rtos should be of use.1 point
-
1 point
-
Edited this out for privacy in the longrun.1 point
-
@mhupp Perfect, I just changed the variable ss to ss1 (sssetfirst nil ss1) Best regards1 point
-
Looks like BricsCAD searches text without case sensitivity or it might be a variable BIGAL and myself have turned on IDK. This will convert everything to uppercase with strcase (for matching with wcmatch) so case sensitivity doesn't matter. ;;----------------------------------------------------------------------------;; ;; Find and Select Text (defun C:FTXT (/ ss ss1 str) (setq ss1 (ssadd)) (setq str (strcat "*" (strcase (getstring "\nPattern to find: ")) "*")) (if (setq ss (ssget "_X" (list '(0 . "*TEXT") (cons 410 (getvar 'ctab))))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (setq obj (vlax-ename->vla-object ent)) (if (wcmatch (strcase (vla-get-TextString obj)) str) (setq ss1 (ssadd ent ss1)) ) ) ) (prompt (strcat (itoa (sslength ss1)) " items found")) (sssetfirst nil ss1) (princ) )1 point
-
Lets see, copy the LISP to notepad, and find "A-ANNO-DIMS", to see where that appears, see what it says, edit the LISP file and see if that is any help. Think I have it, lets try this, if it works. comment about line 26 "_.layer" "_make" "A-ANNO-DIMS" "_color" 2 "" "" ;; <---EDIT if desired to ;; "_.layer" "_make" "A-ANNO-DIMS" "_color" 2 "" "" ;; <---EDIT if desired where ' ; ' tells CAD to ignore what comes after that in the line, should do it1 point
-
The 574 dimension has scale overrides. Pick the 574 dimension and right-click then pick "Dim Style" then pick "Save as new style…" and give it a name. Now that it's a dimension style you can use it to draw other dimensions in the same style. Like eldon I prefer everything drawn true size but there are some exceptions to every rule. I've created a lot of typicals and details in Paper Space which required me to use dimensions with scale values. Once they're complete I use Lee Mac's to fix the values so they'll display correct values even if they were scaled to plot at a different size.1 point
-
;; degrees to rad (defun deg2rad (deg / ) (/ (* deg pi ) 180) ) ;; draws a polyline (defun drawLWPoly (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)))) ;; TCCR for: Two Click Centerline Rectangle (defun c:TCCR2 ( / w ang p1 p2 bl br tl tr) (setq w (getreal "\nWidth: ")) (while (setq p1 (getpoint "\nPoint 1:")) (setq p2 (getpoint "\nPoint 2:" p1)) ;; calculate bottom/left, bottom/right,... (setq ang (angle p1 p2)) (setq bl p1) (setq tl (polar p1 (+ ang (deg2rad 90.0)) w)) (setq br p2) (setq tr (polar p2 (+ ang (deg2rad 90.0)) w)) (drawLWPoly (list bl br tr tl) 1) ) ) @Emmanuel Delay I figured it out!! Having your code helped quite a bit. thanks again.1 point
-
1 point
-
So you want to draw 3 lines from 2 pick pts ? What happens with this. A more specific global style routine may be a better solution, the line intersect points can be found and the lines adjusted. It would still use offset. If you always have a HOR VERT rectang then why not rework out the 4 pts you know offset. You can detect the line/pline at the pick point and get its angle. Its nearly always better to post a diagram of what you want in 1st post.1 point
-
mhupp this may be useful, nentsel to get attribute tag name then use ssget pt where pt is the insertion pt of the tag, this second ssget will then get the block so you can get block name to use. (ssget (list (cons 0 "INSERT")(cons 2 bname)))1 point
-
1 point
-
Not that much of a noob if you recognize the importance of standards.1 point
-
Sorry, I was busy last few days. See this thread...shortening fields in attributes - AutoCAD Drawing Management & Output - AutoCAD Forums (cadtutor.net)1 point
-
Thanks, but I googled abit more while waiting for a reply and found this expression that worked. It is below for anyone else who might be searching for something similar. $(substr,$(getvar,dwgname),$(-,$(strlen,$(getvar,dwgname)),4),1)1 point
-
Get a copy of Notepad++ a text editor has functions built in that helps when writing lisp's. A lot of us use it.1 point
-
https://www.afralisp.net/ is nice with simple step by step instructions. https://www.cadtutor.net/tutorials/autolisp/quick-start.php also good start but one page. Coming to the forums regularly to see how people problem solve. look for answer from people with high scores. there are multiple ways to code things in lisp. usually it comes down to performance (what runs the fastest) but depending on user preference or other factors one type of code might win out over a faster code. Reading over the functions to understand how to use them. https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-4CEE5072-8817-4920-8A2D-7060F5E16547 Welcome and hope to see you around.1 point
-
This should fix it. added an option for the center of pond point still ask for it. But you can right click to get the geocenter for the polyline picked right before. this will work for most boundary's. Odd shaped ones should be picked by hand. ;;----------------------------------------------------------------------------;; ;; POND OFFSET TOPO (defun c:PCA (/ slope depth pndtob pndcnt pt c_pt) (setq slope (getdist "\nPond Side Slope 1:# ")) ;Specify the side slope of the pond (setq depth (getdist "\nPond Depth: ")) ;Specify the depth of the pond (setq pndtob (car (entsel "\nSelect Top of Bank: "))) ;Select a closed polyline (setq pndcnt (osnap (vlax-curve-getStartPoint pndtob) "gcen")) (entmake (list '(0 . "POINT") (cons 10 pndcnt))) (setq pt (entlast)) (or (setq pndcnt (getpoint "\nSelect Approxiamte Center of Pond or [GeoCenter]: ")) (setq pndcnt (osnap (vlax-curve-getStartPoint pndtob) "gcen"))) (setq c_pt (vlax-curve-getclosestpointto (vlax-ename->vla-object pndtob) pndcnt)) (if (< (setq dist (fix (/ (distance pndcnt c_pt) slope))) depth) (prompt (strcat "\nMaximum Depth with slope [" (itoa dist) "]")) (progn (setvar 'cmdecho 0) (repeat (fix depth) (command "offset" slope pndtob pndcnt "_E") (setq pndtob (entlast)) (setq elv (assoc 38 (setq plg (entget pndtob)))) (entmod (subst (cons 38 (1- (cdr elv))) elv plg)) ) (setvar 'cmdecho 1) ) ) (entdel pt) (princ) )1 point
-
hi test this is ;;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-dimension-only-width-and-length-of-a-polyline/m-p/10799893/highlight/true#M424578 (vl-load-com) (defun DP (side / *error* clay cmde styht plsel pl cw inc pt1 pt2 pt3 pt4) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break")) (princ (strcat "\nError: " errmsg)) ); if (setvar 'clayer clay) (setvar 'osmode osm) (command-s "_.undo" "_end") (setvar 'cmdecho cmde) (princ) ); defun -- *error* (setq clay (getvar 'clayer) osm (getvar 'osmode) cmde (getvar 'cmdecho)) (setvar 'cmdecho 0) (setvar 'osmode 0) (if (not *DPseq) (setq *DPseq 1)) (command "_.undo" "_begin" "_.layer" "_make" "A-ANNO-DIMS" "_color" 2 "" "" ;; <---EDIT if desired ); command (setq styht (cdr (assoc 40 (tblsearch "style" (getvar 'dimtxsty))))); height of text style in current dimension style (if (= styht 0.0) (setq styht (* (getvar 'dimtxt) (getvar 'dimscale)))); if above is non-fixed-height (setq s (ssget '((0 . "*POLYLINE")))) ;;; (while ;;; (not ;;; (and ;;; (setq plsel (entsel "\nSelect Polyline: ")) ;;; (wcmatch (cdr (assoc 0 (entget (car plsel)))) "*POLYLINE") ;;; (= (logand (cdr (assoc 70 (entget (car plsel)))) 88) 0) ;;; ;; not 3D or mesh [88 = 8 (3D) + 16 (polygon mesh) + 64 (polyface mesh)] ;;; ); and ;;; ); not ;;; (prompt "\nNothing selected, or not a LW or 2D Polyline.") ;;; ); while (while (setq plsel (ssname s 0)) (setq pl (vlax-ename->vla-object plsel)) (vla-offset pl styht); temporary (setq cw (< (vla-get-area (vlax-ename->vla-object (entlast))) (vla-get-area pl))) ;; clockwise for closed or clearly inside/outside open; may not give ;; desired result for open without obvious inside/outside (entdel (entlast)) (repeat (setq inc (fix (vlax-curve-getEndParam pl))) (setq pt1 (vlax-curve-getPointAtParam pl inc) pt2 (vlax-curve-getPointAtParam pl (- inc 0.5)); segment midpoint pt3 (vlax-curve-getPointAtParam pl (1- inc)) ); setq (if (equal (angle pt1 pt2) (angle pt2 pt3) 1e-8); line segment (command ; then "_.dimaligned" pt1 pt3 "_text" (strcat (itoa *DPseq) ": <>") ); [leaves at dimension line location prompt] (command ; else [arc segment] "_.dimangular" "" (inters ; arc center (setq pt4 (mapcar '/ (mapcar '+ pt1 pt2) '(2 2 2))) (polar pt4 (+ (angle pt1 pt2) (/ pi 2)) 1) (setq pt4 (mapcar '/ (mapcar '+ pt2 pt3) '(2 2 2))) (polar pt4 (+ (angle pt2 pt3) (/ pi 2)) 1) nil ); inters pt1 pt3 "_text" (strcat (itoa *DPseq) ": " (rtos (abs (- (vlax-curve-getDistAtParam pl inc) (vlax-curve-getDistAtParam pl (1- inc)))) 2 0) "mm" ;; [edit mode and precision and suffix as desired -- this is per request on AutoCAD Forum] ); strcat ); command [leaves at dimension line location prompt] ); if (command ; complete Dimension: dimension line location (polar pt2 (apply (if (or (and cw (= side "in")) (and (not cw) (= side "out"))) '- '+) (list (angle '(0 0 0) (vlax-curve-getFirstDeriv pl (- inc 0.5))) (/ pi 2) ); list ); apply (* styht 1.5) ;; [If you don't use stacked fractions, consider using styht without multiplier] ); polar ); command (setq inc (1- inc) *DPseq (1+ *DPseq) ); setq ); repeat (ssdel plsel s) ) (setvar 'clayer clay) (setvar 'osmode osm) (command "_.undo" "_end") (setvar 'cmdecho cmde) (princ) ); defun -- C:DP (defun C:DPI () (DP "in")); = Dimension Polyline Inside (defun C:DPO () (DP "out")); = Dimension Polyline Outside (prompt "\nType DPI to Dimension a Polyline on the Inside, DPO to do so on the Outside.")1 point
-
Sure, I renamed the command CLCL (defun change_layer_color_ltp ( ent / DLname) (setq ;;ent (car esel) DLname (strcat (cdr (assoc 8 (entget ent))) "-DEMO") ) (command "_.layer" "_make" DLname "_color" 40 "" "_ltype" "HIDDEN2" "" "" "_.chprop" ent "" "_layer" DLname "" ) (princ) ) (defun c:clcl ( / ss i) ;; selection (princ "\nMake selection: ") (setq ss (ssget)) ;; now perform the function for every selected entity (setq i 0) (repeat (sslength ss) (change_layer_color_ltp (ssname ss i)) (setq i (+ i 1)) ) (princ) )1 point