Search the Community
Showing results for tags 'autolisp'.
-
Hello everyone i have this code that im working for sometime... (while (not (setq ent (car (entsel "\nSelect rectangle: "))))) What i want is to change the selection option into ssget with layer filter, so that i would not pick the rectangle one by one and will do the same routine for every rectangle in the selection set.
-
hello all;I'm using the code bellow, but i need to click on almost 2000 road cross sections one by one, indeed that is time consuming. it would be more general if the code can select all green lines at ones and then the red lines. mean that, if there be 2000 road cross sections for example; the code can select all cross sections and report a cut and fill file separately for each section (the same as AreaLabelV1-9.lsp of Mr.Lee Mac does)appreciate if anyone can help metnx ;;; Cut & Fill by ymg ; ;;; ; (defun c:cf (/ ** *acdoc* a are b bnd c cutcol d dir dl1 dl2 e fillcol hcol intl len1 len2 p p0 p1 p2 pm pol1 pol2 sp1 sp2 spe ss1 ss2 totcut totfill txt txtlayer varl) (vl-load-com) (defun *error* (msg) (mapcar 'eval varl) (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*"))) (princ (strcat "\nError: " msg)) ) (and *acdoc* (vla-endundomark *acdoc*)) (princ) ) (setq varl '("OSMODE" "CMDECHO" "DIMZIN" "PEDITACCEPT") varl (mapcar (function (lambda (a) (list 'setvar a (getvar a)))) varl) ) (or *acdoc* (setq *acdoc* (vla-get-activedocument (vlax-get-acad-object)))) (vla-startundomark *acdoc*) (setvar 'CMDECHO 0) (setvar 'DIMZIN 0) (setvar 'OSMODE 0) (setq cutcol 1 fillcol 3 ; Cut is Red, Fill is Green ; totcut 0 totfill 0 ; Total Cut and Total Fill ; txtlayer "Text" ; Name of Layer for Cut and Fill Values ; ) (while (not (setq ** (princ "\nSelect Reference Polyline:") ss1 (ssget "_+.:L:S" '((0 . "LWPOLYLINE"))) ) ) (princ "\nYou Must Select a Polyline:") ) (while (not (setq ** (princ "\nSelect Proposed Polyline:") ss2 (ssget "_+.:L:S" '((0 . "LWPOLYLINE"))) ) ) (princ "\nYou Must Select a Polyline:") ) (setq pol1 (ssname ss1 0) len1 (vlax-curve-getDistAtParam pol1 (vlax-curve-getEndParam pol1)) pol2 (ssname ss2 0) len2 (vlax-curve-getDistAtParam pol2 (vlax-curve-getEndParam pol2)) sp1 (vlax-curve-getstartpoint pol1) spe (vlax-curve-getendpoint pol1) sp2 (if (vlax-curve-isClosed pol2) (setq lst2 (listpol pol2) disl (mapcar '(lambda (a) (distance sp1 a)) lst2) ** (plineorg pol2 (nth (vl-position (apply 'min disl) disl) lst2)) ) (vlax-curve-getstartpoint pol2) ) dir (if (< (/ pi 2) (angle sp1 spe) (/ (* 3 pi) 2)) -1 1) ) ; Getting all the intersections between poly. ; (setq intl (intersections pol1 pol2)) (if (> (length intl) 1) (progn ; Computing distance of intersections on each polyline ; (setq dl1 (mapcar '(lambda (a) (getdistoncurve pol1 a)) intl) dl2 (mapcar '(lambda (a) (getdistoncurve pol2 a)) intl) ) ; If both polyline are closed add first Intersection to end of list ; ; We also add a distance to each distances list ; (if (and (vlax-curve-isClosed pol1) (vlax-curve-isClosed pol2)) (setq dl1 (append dl1 (list (+ (car dl1) len1))) dl2 (append dl2 (list (+ (car dl2) len2))) intl (append intl (list (car intl))) dir (if (iscw_p (listpol pol1)) -1 1) ) ) ; Finding points at mid-distance between intersections on each polyline ; ; Calculating midpoint between mid-distance points to get an internal point; ; Creating a list of all these points plus the intersection points ; (setq pm (mapcar '(lambda (a b c d e) (list (midpoint (setq p1 (getptoncurve pol1 (rem (* (+ a b) 0.5) len1))) (setq p2 (getptoncurve pol2 (rem (* (+ c d) 0.5) len2))) ) p1 p2 e ) ) dl1 (cdr dl1) dl2 (cdr dl2) intl ) ) (foreach i pm (setq p (car i) ; Midpoint between p1 p2 ; p0 (cadddr i) ; Intersection Point ; p1 (cadr i) ; Midpoint of Intersections on Reference Polyline ; p2 (caddr i) ; Midpoint of Intersections on Proposed Polyline ; ) (if (> (abs (onside p2 p0 p1)) 1e-3) ; Not Colinear ; (progn (vl-cmdf "._-BOUNDARY" p "") (setq are (vla-get-area (vlax-ename->vla-object (entlast))) bnd (entlast) ) (if (minusp (* (onside p2 p0 p1) dir)) (setq totfill (+ totfill are) hcol fillcol) (setq totcut (+ totcut are) hcol cutcol) ) (vl-cmdf "._-HATCH" "_CO" hcol "." "_P" "SOLID" "_S" bnd "" "") (entdel bnd) ) ) ) (setq p (cadr (grread nil 13 0)) txt (strcat "{\\C3;Fill: " (rtos totfill 2 2) " m2\\P\\C1;Cut: " (rtos totcut 2 2) " m2}") ) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 8 txtlayer) (cons 100 "AcDbMText") (cons 10 p) (cons 40 3.0) (cons 1 txt) ) ) (command "_MOVE" (entlast) "" p pause) ) (Alert "Not Enough Intersections To Process !") ) (*error* nil) ) (princ "\nCalculates Cut & Fill Between Two Intersecting Polylines") (princ "\nCF to start...") (defun midpoint (p1 p2) (mapcar '(lambda (a b) (* (+ a b) 0.5)) p1 p2) ) ; onside by ymg ; ; Negative return, point is on left of v1->v2 ; ; Positive return, point is on right of v1->v2 ; ; 0 return, point is smack on the vector. ; ; ; (defun onside (p v1 v2 / x y) (setq x (car p) y (cadr p)) (- (* (- (cadr v1) y) (- (car v2) x)) (* (- (car v1) x) (- (cadr v2) y))) ) ; ; ; Is Polyline Clockwise by LeeMac ; ; ; ; Argument: l, Point List ; ; Returns: t, Polyline is ClockWise ; ; nil, Polyline is CounterClockWise ; ; ; (defun iscw_p (l) (if (equal (car l) (last l) 1e-8) (setq l (cdr l))) (minusp (apply '+ (mapcar (function (lambda (a b) (- (* (car b) (cadr a)) (* (car a) (cadr b)))) ) l (cons (last l) l) ) ) ) ) ;; ; ;; Return list of intersection(s) between two VLA-Object or two ENAME ; ;; obj1 - first VLA-Object ; ;; obj2 - second VLA-Object ; ;; mode - intersection mode (acExtendNone acExtendThisEntity ; ;; acExtendOtherEntity acExtendBoth) ; ;; Requires triplet ; ;; ; (defun Intersections (obj1 obj2) (or (= (type obj1) 'VLA-OBJECT) (setq obj1 (vlax-ename->vla-object obj1))) (or (= (type obj2) 'VLA-OBJECT) (setq obj2 (vlax-ename->vla-object obj2))) (triplet (vlax-invoke obj1 'intersectwith obj2 acExtendNone)) ) ;; ; ;; triplet, Separates a list into triplets of items. ; ;; ; (defun triplet (l) (if l (cons (list (car l) (cadr l) (caddr l))(triplet (cdddr l)))) ) (defun getdistoncurve (e p) (vlax-curve-getDistatParam e (vlax-curve-getparamatpoint e (vlax-curve-getclosestpointto e p) ) ) ) (defun getptoncurve (e d) (vlax-curve-getpointatparam e (vlax-curve-getparamatdist e d)) ) ;; ; ;; listpol by ymg (Simplified a Routine by Gile Chanteau ; ;; ; ;; Parameter: en, Entity Name or Object Name of Any Type of Polyline ; ;; ; ;; Returns: List of Points in Current UCS ; ;; ; ;; Notes: On Closed Polyline the Last Vertex is Same as First) ; ;; ; (defun listpol (en / i l) (repeat (setq i (fix (1+ (vlax-curve-getEndParam en)))) (setq l (cons (trans (vlax-curve-getPointAtParam en (setq i (1- i))) 0 1) l)) ) ) ;; plineorg by (gile) (Modified into a function by ymg) ; ;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ ; ;; change-polyline-start-point/td-p/2154331 ; ;; ; ;; Function to modify origin of a closed polyline ; ;; ; ;; Arguments: ; ;; en : Ename or VLA-Object of a Closed Polyline. ; ;; pt : Point ; ;; ; ;; Returns: Point of Origin if successful, else nil. ; ;; ; (defun plineorg (en pt / blst d1 d2 d3 n norm obj pa plst) (if (= (type en) 'ENAME) (setq obj (vlax-ename->vla-object en)) (setq obj en en (vlax-vla-object->ename obj)) ) ;; bulgratio by (gile) ; ;; Returns a bulge which is proportional to a reference ; ;; Arguments : ; ;; b : the reference bulge ; ;; k : the ratio (between angles or arcs length) ; (defun bulgratio (b k / a) (setq a (atan b)) (/ (sin (* k a)) (cos (* k a))) ) ;; Sublist by (gile) ; ;; Returns a sublist similar to substr function. ; ;; lst : List from which sublist is to be extracted ; ;; idx : Index of Item at Start of sublist ; ;; len : Length of sublist or nil to return all items. ; (defun sublist (lst n len / rtn) (if (or (not len) (< (- (length lst) n) len)) (setq len (- (length lst) n)) ) (setq n (+ n len)) (repeat len (setq rtn (cons (nth (setq n (1- n)) lst) rtn)) ) ) (if (and (= (vla-get-closed obj) :vlax-true) (= (vla-get-objectname obj) "AcDbPolyline") ) (progn (setq plst (vlax-get obj 'coordinates) norm (vlax-get obj 'normal) pt (vlax-curve-getClosestPointTo en (trans pt 1 0)) pa (vlax-curve-getparamatpoint obj pt) n (/ (length plst) 2) ) (repeat n (setq blst (cons (vla-getbulge obj (setq n (1- n))) blst)) ) (if (= pa (fix pa)) (setq n (fix pa) plst (append (sublist plst (* 2 n) nil) (sublist plst 0 (* 2 n)) ) blst (append (sublist blst n nil) (sublist blst 0 n)) ) (setq n (1+ (fix pa)) d3 (vlax-curve-getdistatparam en n) d2 (- d3 (vlax-curve-getdistatpoint en pt)) d3 (- d3 (vlax-curve-getdistatparam en (1- n))) d1 (- d3 d2) pt (trans pt 0 (vlax-get obj 'normal)) plst (append (list (car pt) (cadr pt)) (sublist plst (* 2 n) nil) (sublist plst 0 (* 2 n)) ) blst (append (list (bulgratio (nth (1- n) blst) (/ d2 d3))) (sublist blst n nil) (sublist blst 0 (1- n)) (list (bulgratio (nth (1- n) blst) (/ d1 d3))) ) ) ) (vlax-put obj 'coordinates plst) (repeat (setq n (length blst)) (vla-setbulge obj (setq n (1- n)) (nth n blst)) ) (trans pt 0 1) ) nil ) )
-
Hello everyone, is there anyone who have lisp routine for drawing clothoides (spirals) between two arcs or "S" curve and who is willing to share it? I hope so that is not to much to ask for. Best Regards!
-
So I've been at this Lisp Routine for a little while now. Done a lot of searching and researching. I'm almost at the finish line and I need some help with the last few steps. Or at least, the next to last step. So the ultimate goal here is to use our column grid to generate an indicator at intersections. Grid is created more or less by hand so it will always vary. I decided to use the method of placing blocks with attributes at selected column lines' intersections. I've taken care of selection issues of DTEXT vs MTEXT and assigning LINE objects with said TEXT objects. I've whittled down what I would call the big issues except for one. My final result has been a list of "pairs" like this example: (((-2376.0 -504.001 0.0) L) ((-2376.0 -504.001 0.0) ((-2016.0 -504.001 0.0) L) ((-2016.0 -504.001 0.0) 7.1)...) The first part of each item is a point list followed by the corresponding text/string to be used for the block attributes. Problem is I need to combine the items with the same point so that each item will be as follows (((-2376.0 -504.001 0.0) 8 L) ((-2016.0 -504.001 0.0) 7.1 L)...). Now I believe I can workout the order in which they are listed to suit my purposes, but I'm having trouble just combining the two strings with the same point. After this hurdle, I'll need to insert the block WITH those strings filling in the attributes, but I believe I can figure that part out. I've attached a drawing with a sample grid and the lisp routine I've pieced together so far. Here's the main portion of the code in case that's all someone needs: (defun c:setupint (/ mspc ss_txt ss_lines pntlst grdlst attlst i_pnt i_grd ob_pnt ob_grd pnt1 pnt2 pnt3 ob_strg blk) (setq mspc (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (and (princ "\nSelect Grid Text: ") (setq ss_txt (ssget '((0 . "TEXT,MTEXT")))) (princ "\nSelect Grid Lines: ") (setq ss_lines (ssget '((0 . "LINE")))) (setq pntlst (SF:sortyx (LM:intersectionsinset ss_lines))) (setq grdlst (MT:GrdAcList ss_lines ss_txt)) ) (repeat (setq i_pnt (length pntlst)) (setq ob_pnt (nth (setq i_pnt (1- i_pnt)) pntlst)) (repeat (setq i_grd (length grdlst)) (setq ob_grd (nth (setq i_grd (1- i_grd)) grdlst) pnt1 ob_pnt pnt2 (vlax-curve-getStartPoint (cadr ob_grd)) pnt3 (vlax-curve-getEndPoint (cadr ob_grd)) ob_strg (car ob_grd) ) (if (LM:Collinear-p pnt1 pnt2 pnt3) (setq attlst (cons (list ob_pnt ob_strg) attlst)) ;list of text with corresponding point ) ) ;end repeat grd ) ;end repeat pnt ) (setq blk "setupint") (princ attlst) ;Test Print of list ;;; (foreach itm attlst ;;; (setq p (list (nth 0 (car itm)) (nth 1 (car itm)) (nth 2 (car itm)))) ;;; (princ p) ;;; (vla-insertblock mspc (vlax-3D-point p) blk 1.0 1.0 1.0 0) ;;; ) ) (vl-load-com) (princ) SETUP TEST.dwg setupintV2.lsp
-
Changing the justification/dragline of my Pipe routine
egjg1234 posted a topic in AutoLISP, Visual LISP & DCL
Hello guys! New to the forum but have been looking at this forum for help for a few years now and has been very helpful for my auto cad education and career! I have this lisp routine that creates a pline in each side of the original pline to create this stormwater pipe. I've been trying to figure out how I can start the offset from the bottom line instead of the middle pline to no avail. Is there anyone that help me with this? Changing the justification of the dragline could save me hours creating details for work. Thanks a bunch! ; STORMWATER.LSP (defun c:SWPIPE () ;(/ PT PT1 PT2 WID ELAST KTEMP E1 E2 ang1 ang2) (setvar "CMDECHO" 0) (initget 1) (setq PT (getpoint "\nStart point: ")) (command ".PLINE" PT "W" 0 0) (setq PT1 PT PT0 PT) (while (setq PT (getpoint PT "\nNext point: ")) (setq PT2 PT) (command PT) ) (setq ang1 (-(angle pt1 pt2)(/ pi 2)) ang2 (+ ang1 pi)) (command) (SETQ OS (GETVAR "OSMODE")) (setvar "osmode" 0) (initget 4) (setq ELAST (entlast) KTEMP (getdist "\nLine width<0.0>:") WID ktemp ; WID (* (if KTEMP KTEMP 0.0416) (GetVar "LTSCALE"));old UserR1 ; PT1 (reverse (cdr (reverse PT1))) ) (command ".OFFSET" (/ WID 2) (list ELAST PT1) (polar PT1 ang1 0.1)"") (setq E1 (entlast)) (command ".OFFSET"(/ WID 2) (list ELAST PT1) (polar PT1 ang2 0.1) "") (setq E2 (entlast)) (command ".PEDIT" ELAST "W" WID "" ".CHANGE" ELAST"" "P" "LT" "HIDDEN1" "") (redraw E1) (redraw E2) (princ)S (setvar "osmode" 0) ) SWPIPE.LSP -
Hello, After a sidestep to Clojure, of course back to AutoLisp. I have quite some exeperience with AutoLisp and on and off I worked with it for almost 20 years now. (Auto)Lisp is known amongst AutoCAD users but further on, the whole lisp-thing doesn't ring a bell with most programmers that I meet. They work with SQL, HTML, XHTML, Java, C# or maybe (V)BA. I stayed interested in Lisp, although limited to AutoLisp. Recently. I discovered that there is a new Lisp called Clojure that is becoming big in the programming world. Possibly due to the fact that it translates to Java or javascript before anything is executed. But this aside. I learned that Clojure is first class because it is capable of accepting a function as a parameter and clojure functions can produce functions. There's a whole lot more to be discoverd about this great language but I leave that to the reader. The subject 'Clojure' is easily found on the web. By taking this interest in Clojure I learned a lot about AutoLisp too. On this page at the subject of 'Closures' halfway the page, there is an example showing how a function is produced in Clojure. Realy, it took me quite some time to grasp it. After that I wanted to know if this could be done with AutoLisp as well. After trials with defun-q-list-set/ref (which also work) I came up with the following. Hart of the solution is (eval (append '(lambda . . Is it the best way to do this? I don't know. Is it useful? I doubt it but see below. Is it interesting? Highly (for me!) (defun messenger-builder (greeting) (setq greeting (strcat "\n" greeting " ")) (eval (append '(lambda (who)) (list (list 'princ (list 'strcat greeting 'who)) '(princ))))) (setq hello-er (messenger-builder "Hello") goodbye-er (messenger-builder "Goodbye")) (defun c:greet_the_world () (hello-er "World!")) (defun c:say_goodbye () (goodbye-er "Everyone!!")) AutoLisp does a great job in AutoCAD. Perfect, but as a Lisp it is less thoroughly designed than Clojure. This shows off in the example above. Clojure handles the subject of producing functions easier. Maybe my example is ill-constructed. I could not find a better solution. Question also is, can we think of any usufull application of this in AutoCAD. Although I took another route in the example, the designated functions for this are (I think) defun-q-list-set/ref. I suppose they are there for a reaon. Or is it all limited to the s::startup example?
-
Hi I work in a company, people come to us with their plot registry, on which are the dimensions (north,east,south,west) and area of their plots. But there are no angles. For example, a plot of 25 * 10 meters with an area (according to the mathematical calculations) should be 250 square meters. But 244.95 is listed on the registry.My question is how do I quickly draw this plot (according to the registry) in AutoCAD? Is there any lisp for this?
-
Lisp to change title block attributes in layout tabs
kmfdk posted a topic in AutoLISP, Visual LISP & DCL
I want to change attribute text in title blocks, calling the block by the block name, not selecting the block, looping thru all the layout tabs. The title block will have the same name on each layout. My titleblock is named TITLEBLOCK30x42, with 2 attributes SHEET-TITLE and SHEET-DESCRIPTION. This thread talks about doing the same thing. None of the small generic code posted in that thread works for me. https://www.cadtutor.net/forum/topic/63734-lisp-code-to-select-block-in-layouts-and-update-attributes/- 5 replies
-
- autolisp
- titleblock
-
(and 1 more)
Tagged with:
-
Select Specific Blocks by knowing their names
Ahmed_Hisham posted a topic in AutoLISP, Visual LISP & DCL
Hi all, I want to select specific block by knowing its name lets say block name "cadtutor block 1" by using (vl-catch-all-apply) method Thanks -
Send Wipeout to Back of Draworder within Block Definition
b_gum posted a topic in AutoLISP, Visual LISP & DCL
So I have been trying to figure this out with several approaches now and I need some help. I would like to send all Wipeouts, or really any specified entity type, within a block to the back of the draw order. Is there a way to do this using Lee Mac's Apply To Block Objects routine? I tried this in conjunction with his draw order routines but the MovetoBottom command kept failing. I'm pretty rough with VisualLisp which is part of the issue when trying to troubleshoot his great routines. Or what about this approach? (I dont really understand it, again Visual Lisp) Below is what I tried. I do understand Vanilla Lisp. Visual Lisp I barely know the basics, but eager to learn. Please help me improve my capabilities. I love autolisp. Thank you. The issue is clearly with the lambda function and my improper use of it Im sure. The ssget I am trying to do is incorrect approach for use with his function. ;=========================================================== ; 11/Sep/2020 10:09 AM[Friday] AUTHOR: Brandon Gum ;-- ;DESCRIPTION: ;Select block with wipeout. ;Will send wipeout objects the back of the draw orer ;=========================================================== (defun c:test ( / s ) (princ "\nSelect Block: ") (if (setq s (ssget "_+.:E:S" '((0 . "INSERT")))) (LM:ApplytoBlockObjects (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-effectivename (vlax-ename->vla-object (ssname s 0))) '(lambda ( obj ) (BG:WipeoutToBottom)) ) ) (princ) ) (vl-load-com) (princ) (defun BG:WipeoutToBottom( / ) (LM:movetobottom (ssget "X" '((0 . "WIPEOUT")))) ;(princ) );end of defun ;===============Below here are Lee's draw order functions============== My LeeMac Based Approach.LSP -
Hi, this is my first post. I am trying to draw five circles, one in the centre (x=0, y=0) and the other four, located in each quadrant of circle located in (0,0). I have written the script below but, I does not work. The circles with negative coordinates are drawn on top of the other with positive coordinates. I do not understand, why is this behavior, if you know please let me know. (defun C:he () (setq r 10.0) (command "circle" (list 0 0) r "") (command "circle" (list 5 0) r "") (command "circle" (list -5 0) r "") (command "circle" (list 0 5) r "") (command "circle" (list 0 -5) r "") ) Thanks
-
Hi guys, I'm new to this forum and new to programming with lisp - please be kind.... The code I am writing will draw a 3dPolyline from a specific point to another point (usually with a lower z coordinate), the polyline will then be converted to a spline, a circle will be drawn at the start of the 3dPolyline and extruded along the spline to form a "curved tube". The intention is to use this as a flexible duct from a "spigot" on an A/C duct to a ceiling diffuser. The 3dPoly has to be perpendicular to the start point and end point for obvious reasons - see intentional misalignment picture. Below a portion of the unfinished code to select the start point, select the endpoint, then it must start drawing the 3dpoly from the start point, get a variable number of user input points (in order to define the initial direction and plane) and general path of the flexible duct. The end point of the 3dpoly is already defined with the initial selection of the "Endpoint on Diffuser" although the 2nd last point has to be mathematically determined considering the plane must be perpendicular to the end point. So - after selecting say 3 or 4 user defined points along the path, I want to be able to press enter, and the code must then calculate the 2nd last point and continue drawing the 3dpoly from the last picked point, to the calculated 2nd last point and then to the endpoint. Generally one has to be mindful that the curve of the tube cannot have a "sharp bend" - smooth curves are ideal for the airflow. The diameter of the tube will also change depending on the specific size requirements. Attached a small drawing and picture to show the intent. The crux of my problem: I cannot figure out how to start the 3dpoly command, make it pick the start of the line, then hand over to the user to continue picking 4 or 5 points, press enter, and then continue drawing the 3dpoly with calculated numbers? Would really appreciate some guidance. Maybe use of cmdactive? I really do not know enough to figure this one out. (defun C:Flex250 () (command "_.layer" "_thaw" "HVAC Flex" "_make" "HVAC Flex" "") (setq Prev_OM (getvar "OSMODE")) (setvar "OSMODE" 8) (setq StartPoint (getpoint "\nEnter Start Point on Duct Spigot : ")) (setq EndPoint (getpoint "\nEnter End Point on Diffuser : ")) (setq Z0 (caddr EndPoint)) (setq Z1 (+ (caddr EndPoint) 50)) (setq Z2 (+ (caddr EndPoint) 150)) (setq pt0 EndPoint) (setq pt1 (list (car EndPoint) (cadr EndPoint) Z1)) (setq pt2 (list (car EndPoint) (cadr EndPoint) Z2)) (SetVar "Elevation" (princ (caddr StartPoint))) (command ".3DPoly" (princ Startpoint) (getpoint "\nNext point : ") pt2 pt1 pt0) ) Then a last question - is there a way to ensure the spline's start and finish points are 100% perpendicular to the planes they connect to? Thank you in advance for your input. Test.dwg
- 1 reply
-
- user input
- 3dpoly
-
(and 3 more)
Tagged with:
-
Automatic Dimensioning for Blocks in Autocad
Ahmed_Hisham posted a topic in AutoLISP, Visual LISP & DCL
Good Day, I want the attached code to run as QDIM in Autocad , My issue in my code that I choose the location of the dimension line after that the dimension appears. I want to see all the dimensions afterwards choose the location like in QDIM command. Thanks (vl-load-com) (defun C:FH ( / *error* doc oVAR ss i pts ptsx ptsy d d0 filter ) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break")) (princ (strcat "\nError: " errmsg))) (foreach e oVAR (setvar (car e) (cdr e))) (vla-endundomark doc) (princ)) ;------------------------------------------------------------------------------------------------------ (vla-startundomark (setq doc (vla-get-activedocument (vlax-get-acad-object)))) (foreach e '(CMDECHO ORTHOMODE) (setq oVAR (cons (cons e (getvar e)) oVAR))) (setvar 'CMDECHO 0) (setvar 'ORTHOMODE 0) (if (and (princ "\nNeed blocks, ") (setq ss (ssget (list '(0 . "INSERT")))) (< 1 (setq i (sslength ss))) (while (not (minusp (setq i (1- i)))) (setq pts (cons (cdr (assoc 10 (entget (ssname ss i)))) pts))) (setq ptsx (vl-sort pts '(lambda (p q) (< (car p) (car q))))) (setq ptsy (vl-sort pts '(lambda (p q) (< (cadr p) (cadr q))))) (setq d (abs (/ (- (car (last ptsx)) (caar ptsx)) ;xmax-xmin (if (zerop (setq d0 (- (cadr (last ptsy)) (cadar ptsy)))) ;ymax-ymin 0.001 d0)))) (setq pt (getpoint "\nSpecify dimension line location: ")) (or *DimTypeBDA (setq *DimTypeBDA "Aligned")) (not (initget "Horizontal Vertical Aligned")) (setq *DimTypeBDA (cond ((getkword (strcat "\nType of dimension [" (cond ((> d 1000.) (if (= *DimTypeBDA "Vertical") (setq *DimTypeBDA "Horizontal")) "Horizontal") ((< d 0.001) (if (= *DimTypeBDA "Horizontal") (setq *DimTypeBDA "Vertical")) "Vertical") ("Horizontal/Vertical")) "/Aligned] <" *DimTypeBDA ">: "))) (*DimTypeBDA))) (setq pts (if (or (= *DimTypeBDA "Horizontal") (and (= *DimTypeBDA "Aligned") (> (- (car (last ptsx)) (caar ptsx)) (- (cadr (last ptsy)) (cadar ptsy))))) ptsx ptsy)) (setq i 0) ) (repeat (1- (length pts)) (cond ((= *DimTypeBDA "Horizontal") (command "_.DIMLINEAR" "_none" (nth i pts) "_none" (nth (1+ i) pts) "_H" "_none" pt)) ((= *DimTypeBDA "Vertical") (command "_.DIMLINEAR" "_none" (nth i pts) "_none" (nth (1+ i) pts) "_V" "_none" pt)) (T ;Aligned (command "_.DIMALIGNED" "_none" (nth i pts) "_none" (nth (1+ i) pts) "_none" pt))) (setq i (1+ i))) (princ (strcat "\nError: Wrong selection of at least 2 BLOCKS."))) (foreach e oVAR (setvar (car e) (cdr e))) (vla-endundomark doc) (princ) ) FH Final.LSP -
I work for a glazing company where we do all our glass sizing manually and am looking for a way to do it automatically. I am not very knowledgeable in Lisp. So we have a block we use to put the sizes into. I was wondering if it is possible for a lisp to read the size of a rectangle that has the block inside of it and put dimensions into the specified area. The block also has multiple Visibility's to fit in different places. There is also multiple visibility's for the reason that I made it for multiple people with different preferences. (See dwg. file below for block). Is this at all possible? Callout_GL.dwg
-
autolisp Need lisp for export cad text / table in excel.
Mohanm posted a topic in AutoLISP, Visual LISP & DCL
Dear Team member, I have more number of BOQ table in Auto Cad. Need to export that table and text to excel in editable format. Can anyone help and share the lisp for export cad text / table in excel. Thanks. Mohan -
I can convert my raw AutoLISP (.lsp) codes into Visual Lisp (.VLX) and .FAS application using AutoCAD VLISP IDE. I was looking into Autodesk App Store and downloaded some of the free applications. It was .msi. That means it will install directly on Windows and link-up with installed AutoCAD. I am very new in the App Store. Could you please help me to understand to convert my .lsp or .vlx or .fas into .msi? Thanks.
- 4 replies
-
- autolisp
- visual lisp
-
(and 3 more)
Tagged with:
-
I did a program in Autolisp, so I want to encript that in order to avoid hacks. What would you recommend me? Because I want rent it. Im a beginner, so I dont know to much about the topic. Thanks to much for your advices
-
Hi, I need help. My AutoLISP works well in DWG To PDF but it comes out 1 file per 1 DWG. I want it to be the only PDF file. Can somebody help me with something? (I can't use third party programs) Thank you for your help. The examples are in my attachments. My_Plot.LSP Test.dwg
-
help for small change in big lisp routine required
shortkrish posted a topic in AutoLISP, Visual LISP & DCL
Dear all, I have lisp dcl and data files working together to draw steel sections. I have done all the sections modified to indian standards originally it was written for british standards and it is free of copy rights. Since the author has changed to catia 3 dacades before. Please find attached images of error, dialog box and lisp files,data files and dcl files. This may looks like a big job. If any lisp expert available he can do it seconds. As I have done whole lot of things with minimum lisp knowledge. Thanks Krish stl_ipn.dat stl_rsj.dat stl_deflt.dat STL.LSP stl_rtee.dat stl_ub.dat stl_rhs.dat stl_shs.dat stl_uc.dat stl_ursa.dat stl_ersa.dat stl_chs.dat stl_rsc.dat stl_pfc.dat stl_ipe.dat rec.dwg stl_passwd.dat stl_pipe.dat stl_steeub.dat stl_steeuc.dat stl_u.dat stl_ubp.dat stl_upn.dat stl_wash.dat README.TXT stl.dcl stl.slb stl_cap.dat stl_csk.dat stl_cub.dat stl_cuc.dat stl_hd.dat stl_he.dat stl_hex.dat stl_hl.dat stl_hp.dat stl_hx.dat -
Copy Multiple Block Attributes from one block to another one click
lamonmar posted a topic in AutoLISP, Visual LISP & DCL
I have a drawing that has two different blocks (see attached), what I needed to do was transfer over the attributes of one block over to the other (both have different tags). For example copying over attributes in "rev0_date" from the first block tag over to "revslot1date" in the second block tag , I ran across some code in the forums that did just that created by Lee Mac.The problem with it is it only transfers one attribute over, I modified it a little but its still not exactly what I need. The way it currently works is - It asks me to choose the first block with the attributes to copy, once selected it then asks me to choose the second block that will have the attributes pasted to it, once I've selected them, it then pastes the first specified tag attribute in the first block to the second, after that I have to repeat the process again, clicking the block with the attribute to copy and then choosing the second block to paste, I have to keep repeating these steps, clicking the first block then the second over and over until all the tag attributes have been copied over. My question is how can I stop having click the first and then second block over and over again for each tag and instead only have to go through the process once (click first block, then second and then transfer all the attributes over at once). Here is my current code (sorry if its a mess I'm very new to this): (defun c:blockswap ( / _SelectBlockWithTag a b des src tag ) (vl-load-com) (setq DAT1A "Rev0_Date" ; Source Attribute Tag 1 DES1A "Rev0_Desc" ; Source Attribute Tag 2 REV1A "Rev0" ; Source Attribute Tag 3 RDB1A "Rev0_Drawn_By" ; Source Attribute Tag 4 REV1B "RevSlot1Number" ; Destination Attribute Tag 3 DES1B "RevSlot1Description" ; Destination Attribute Tag 2 DAT1B "RevSlot1Date" ; Destination Attribute Tag 1 RDB1B "RevSlot1DrawnBy" ; Destination Attribute Tag 4 ) (defun _SelectBlockWithTag ( tag / e a ) (setq tag (strcase tag)) (while (progn (setvar 'ERRNO 0) (setq f (car (entsel (strcat "\nSelect Block with attribute " tag ": ")))) (cond ( (= 7 (getvar 'ERRNO)) (princ "\nMissed, Try Again.") ) ( (not f) nil ) ( (and (eq "INSERT" (cdr (assoc 0 (entget f)))) (= 1 (cdr (assoc 66 (entget f)))) ) (if (not (setq z (vl-some (function (lambda ( x ) (if (eq tag (strcase (vla-get-tagstring x))) x) ) ) (vlax-invoke (vlax-ename->vla-object f) 'getattributes) ) ) ) (princ (strcat "\nBlock does not contain tag " tag ".")) ) ) ( (princ "\nInvalid Object Selected.") ) ) ) ) z ) (and (setq aa (_SelectBlockWithTag DAT1A)) (setq ab (_SelectBlockWithTag DAT1B)) ) (vla-put-textstring ab (vla-get-textstring aa)) (and (setq ba (_SelectBlockWithTag DES1A)) (setq bb (_SelectBlockWithTag DES1B)) ) (vla-put-textstring bb (vla-get-textstring ba)) (and (setq ca (_SelectBlockWithTag REV1A)) (setq cb (_SelectBlockWithTag REV1B)) ) (vla-put-textstring cb (vla-get-textstring ca)) (and (setq da (_SelectBlockWithTag RDB1A)) (setq db (_SelectBlockWithTag RDB1B)) ) (vla-put-textstring db (vla-get-textstring da)) (princ) ) drawing.dwg -
Im beginner, I have this: (setq p1 (getpoint "\nPunto Inicial:")) (setq p2 (polar p1 (* 1.5 pi) 0.5)) (entmakex (list '(0 . "line") (cons 10 p1) (cons 11 p2) '(62 . 2))) So, the line I drawn is the yellow one below in the image. And, the text I want put is the magenta one. how can I do this? Thanks for your help
-
how to change a color of a line previusly drawn with Autolispp
danyra posted a topic in AutoLISP, Visual LISP & DCL
Im a begginer, I drawn a line in autolisp with this "code": (setq p1 (getpoint "\nPunto Inicial:")) (setq p2 (polar p1 (* 1.5 pi) 0.18)) (command "line" p1 p2 "") but, how can I change the color of this line?? For example I want yellow Thanks for your help. -
Assigning and Custom Drawing Property to a variable
juicyorange posted a topic in AutoLISP, Visual LISP & DCL
Hey guys, I'm looking to assign a custom property to a variable and I have no idea how to do it. In the 0 custom prop I put a testvalue Here is the code I have so far: (vl-load-com) (defun c:test (/) (setq acadObject (vlax-get-Acad-Object) acadDocument (vla-get-Activedocument acadObject) ;; set existing custom properties to dProps dProps (vlax-get-property acadDocument 'Summaryinfo) ) ;; get the value at the specifed index in the dProps and assign it to location (vla-GetCustomByIndex dProps 0 "IMPCSVLOC" location) ) I can't find any documentation on the "vla-GetCustomByIndex" so I don't really know how to use tbh. I've attached a file that has the custom property setup. All insight and help is appreciated. Thanks, JT testfile.dwg- 6 replies
-
- autolisp
- custom proerties
-
(and 2 more)
Tagged with:
-
takes out the coordinates of several polylines with a .txt file
asra posted a topic in AutoLISP, Visual LISP & DCL
Hello is it possible to make lisp to extract coordinates from several polyline lines and their titles in the form of a .txt file? I have an example of the attachment below, I hope someone can help me, thank you. OUTPUT.txt MASTER CROSS SECTION.dwg -
Export Enhanced Attributes Editor Values to Excel
MajorTom posted a topic in AutoLISP, Visual LISP & DCL
Hi, I'm new around here so, I couldn't find the solutions please don't mad me if this request already written by someone else. And also sorry about my grammer either The thing what I want to do : I have a folder and this folder is include many dwg files. And these dwg files contetnts one or more layouts. I'm using Enhanced Attribute Editor for keep data like; <drawing number>, <drawing name>, <date>, <revision no> etc. So I need a lisp for export these data to an excel file . thanks in advance for any help Truly Regards