Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 11/05/2026 in Posts

  1. A couple of points to make: The need to create thousands of variables on-the-fly typically points to poor program design; in almost every case, a list is more suitable. Setting all such variables to nil at the end of the program does clear them from the document namespace, but consider that you are essentially creating & clearing global variables that are not local to the scope of your program, and as such, the variable names could potentially clash with identically named variables in the document namespace - this is generally considered bad practice.
    5 points
  2. You can use AutoLISP's setpropertyvalue to change the Annotative property to No without deleting the objects. LISP code=>(setpropertyvalue (car (entsel "\nSelect object: ")) "Annotative" 0) For processing nested objects, you would also need to iterate through the block definitions and apply the same change to their entities. Xrefs cannot be modified this way without editing their source drawings. This is a useful alternative to manually changing each object's Properties palette.
    2 points
  3. I wonder if exporting the Attribute Values to Excel, then back into the new titleblock would be better? @Lee Mac has Update Titleblock Attributes | Lee Mac Programming and @ziele_o2k has... Export Title Blocks to CSV for Lee's Update Title Block - AutoLISP, Visual LISP & DCL - AutoCAD Forums
    2 points
  4. A contrived exercise to demonstrate the performance considerations: (defun foo1 ( lst ) (vl-sort lst (function (lambda ( s1 s2 ) (compare (splitstr s1) (splitstr s2)) ) ) ) ) (defun foo2 ( lst ) (mapcar '(lambda ( n ) (nth n lst)) (vl-sort-i (mapcar 'splitstr lst) 'compare) ) ) (defun compare ( l1 l2 / x y ) (while (and l1 l2 (= (setq x (car l1)) (setq y (car l2)))) (setq l1 (cdr l1) l2 (cdr l2) ) ) (cond ( (null l1)) ( (null l2) nil) ( (and (numberp x) (numberp y)) (< x y) ) ( (numberp x)) ( (numberp y) nil) ( (< (strcase x) (strcase y))) ) ) (defun splitstr ( str ) (read (strcat "(" (vl-list->string (apply 'append (mapcar (function (lambda ( a ) (if (< 47 a 58) (list a) (list 34 a 34) ) ) ) (vl-string->list str) ) ) ) ")" ) ) ) _$ (setq mylist (makelist 100)) ("byo547swd" "niq983ocu" "aca823vdk" "wtq568rur" "phi902niq" "bjh526uzd" "rji359jxn" "qqv937rwf" "tug083pja" "gad189ena" "lte537pir" "laa124lqe" "pjd997nvz" "opt105nif" "lbg559zsq" "tpj226ohq" "jdo941odr" "pyl665lro" "hoi547oxb" "tke599mge" "tqm797yrt" "dlm480ido" "jlt529gio" "dtl751rtz" "lpi310zks" "rit617cpr" "qdf999kec" "lkz260ohj" "xlg106fuk" "dqj592rbs" "rza409lss" "phx280fll" "rft924rac" "xrt327nir" "mil320zdh" "sec951fzz" "hng963son" "bhm360nws" "whv768vre" "sub738cgn" "udp152qpy" "bfv499vpg" "bef375dxu" "sne299abt" "jwg218naf" "kul046lji" "opm274fep" "xqb135wrk" "vug239ccx" "yvk063bnl" "cca701lfg" "upy690bri" "nsj806ovt" "igt413wky" "ftw622pra" "jsm813cre" "fnd378khc" "utk011unn" "hkm488zlv" "naw752kdp" "gze062nrv" "ytt910gzi" "eeq942uez" "rbm719yzv" "adu204kgv" "voo553bzq" "qah335lvg" "oky453mna" "bye070dci" "uwt849qig" "nkg662cbj" "koy546cve" "fgp548fhm" "hxm087okh" "atb056yvr" "jxz680bdn" "ofc383clx" "ran801jgt" "dai951aut" "muc372eji" "dmv843wdj" "mwl251acq" "skn266edb" "stz033eih" "qbm300sjp" "tax196nfk" "uix079eqf" "evl716cui" "tjl236dov" "mod149kqp" "cai814mxb" "yyf245cfk" "occ503uit" "csd182gul" "jgs728fmy" "hga698aqi" "hfk752ize" "vra872olq" "bjm266zaq" "zva674kji") _$ (foo1 mylist) ("aca823vdk" "adu204kgv" "atb056yvr" "bef375dxu" "bfv499vpg" "bhm360nws" "bjh526uzd" "bjm266zaq" "bye070dci" "byo547swd" "cai814mxb" "cca701lfg" "csd182gul" "dai951aut" "dlm480ido" "dmv843wdj" "dqj592rbs" "dtl751rtz" "eeq942uez" "evl716cui" "fgp548fhm" "fnd378khc" "ftw622pra" "gad189ena" "gze062nrv" "hfk752ize" "hga698aqi" "hkm488zlv" "hng963son" "hoi547oxb" "hxm087okh" "igt413wky" "jdo941odr" "jgs728fmy" "jlt529gio" "jsm813cre" "jwg218naf" "jxz680bdn" "koy546cve" "kul046lji" "laa124lqe" "lbg559zsq" "lkz260ohj" "lpi310zks" "lte537pir" "mil320zdh" "mod149kqp" "muc372eji" "mwl251acq" "naw752kdp" "niq983ocu" "nkg662cbj" "nsj806ovt" "occ503uit" "ofc383clx" "oky453mna" "opm274fep" "opt105nif" "phi902niq" "phx280fll" "pjd997nvz" "pyl665lro" "qah335lvg" "qbm300sjp" "qdf999kec" "qqv937rwf" "ran801jgt" "rbm719yzv" "rft924rac" "rit617cpr" "rji359jxn" "rza409lss" "sec951fzz" "skn266edb" "sne299abt" "stz033eih" "sub738cgn" "tax196nfk" "tjl236dov" "tke599mge" "tpj226ohq" "tqm797yrt" "tug083pja" "udp152qpy" "uix079eqf" "upy690bri" "utk011unn" "uwt849qig" "voo553bzq" "vra872olq" "vug239ccx" "whv768vre" "wtq568rur" "xlg106fuk" "xqb135wrk" "xrt327nir" "ytt910gzi" "yvk063bnl" "yyf245cfk" "zva674kji") _$ (foo2 mylist) ("aca823vdk" "adu204kgv" "atb056yvr" "bef375dxu" "bfv499vpg" "bhm360nws" "bjh526uzd" "bjm266zaq" "bye070dci" "byo547swd" "cai814mxb" "cca701lfg" "csd182gul" "dai951aut" "dlm480ido" "dmv843wdj" "dqj592rbs" "dtl751rtz" "eeq942uez" "evl716cui" "fgp548fhm" "fnd378khc" "ftw622pra" "gad189ena" "gze062nrv" "hfk752ize" "hga698aqi" "hkm488zlv" "hng963son" "hoi547oxb" "hxm087okh" "igt413wky" "jdo941odr" "jgs728fmy" "jlt529gio" "jsm813cre" "jwg218naf" "jxz680bdn" "koy546cve" "kul046lji" "laa124lqe" "lbg559zsq" "lkz260ohj" "lpi310zks" "lte537pir" "mil320zdh" "mod149kqp" "muc372eji" "mwl251acq" "naw752kdp" "niq983ocu" "nkg662cbj" "nsj806ovt" "occ503uit" "ofc383clx" "oky453mna" "opm274fep" "opt105nif" "phi902niq" "phx280fll" "pjd997nvz" "pyl665lro" "qah335lvg" "qbm300sjp" "qdf999kec" "qqv937rwf" "ran801jgt" "rbm719yzv" "rft924rac" "rit617cpr" "rji359jxn" "rza409lss" "sec951fzz" "skn266edb" "sne299abt" "stz033eih" "sub738cgn" "tax196nfk" "tjl236dov" "tke599mge" "tpj226ohq" "tqm797yrt" "tug083pja" "udp152qpy" "uix079eqf" "upy690bri" "utk011unn" "uwt849qig" "voo553bzq" "vra872olq" "vug239ccx" "whv768vre" "wtq568rur" "xlg106fuk" "xqb135wrk" "xrt327nir" "ytt910gzi" "yvk063bnl" "yyf245cfk" "zva674kji") _$ (equal (foo1 mylist) (foo2 mylist)) T _$ (benchmark '((foo1 mylist) (foo2 mylist))) Benchmarking ..........Elapsed milliseconds / relative speed for 128 iteration(s): (FOO2 MYLIST).....1953 / 4.84 <fastest> (FOO1 MYLIST).....9453 / 1.00 <slowest>
    2 points
  5. If you're worried about the removal of duplicated elements when using (vl-sort), just use (vl-sort-i) to obtain the sorted indices and use them to order the original list - this has been solved/demonstrated many times over and is also typically far more performant when sorting lists for which the sort function would otherwise perform some manipulation of the list elements. _$ (setq mylist '(5 3 6 4 5 3 7 5)) (5 3 6 4 5 3 7 5) _$ (vl-sort mylist '<) (3 4 5 6 7) _$ (mapcar '(lambda ( n ) (nth n mylist)) (vl-sort-i mylist '<)) (3 3 4 5 5 5 6 7)
    2 points
  6. Yeah lisp is a little on the background right now , wife has some serious health issues so my attention lies elsewhere at this moment. The 'good' news is I'm running out of work this month so next month I have a lot of spare time. Will do some reading and maybe / probably some lisping too.
    2 points
  7. @PGia there are other ways to sort lists other than inbuilt Vl-sort. You can use a Lisp version of Bubble sort and other sort algorithms. I sort up to 5 items deep in a list and as far as I can tell none are lost. Yes have seen that with some lists using VL-sort. So you can sort on say X & Y. ; sorts on 1st two items (vl-sort lst '(lambda (a b) (cond ((< (car a) (car b))) ((= (car a) (car b)) (< (cadr a) (cadr b))) ) ) )
    2 points
  8. sure : (alert "Press ok to start your 30hr day") anything else I can do for you?
    2 points
  9. AutoCAD session, you need to use vl-bb-set vl-bb-ref right?
    2 points
  10. I get that @PGia but it almost be harder to recall the correct random variable. associated list might not be what you need with the large data set your working with. as assoc looks at all 20000 records every time. look into Dictionary before going the other route. alot faster searching because you can only have unique keys tho that might be a deal breaker for you.
    2 points
  11. There may be ways to speed up using a list of 20,000 points, the first is if your points are numbered then make the list that way you have to but pt number 0 as 1st item then a (nth x lst) is a simple task and does not need the (- x 1). Re find a point depending how the list is made there is a way of quickly finding the point based on a sorted list a 10,000 list takes 13 tries to find the correct answer, it uses a 1/2 algorithm, look at 5000 item is it before or after look at say 2500 is it before or after so very fast. Can you explain what it is your doing and maybe some people here can provide faster code. I know something I did took 34 minutes 1st go, it now takes 2 minutes including user input.
    2 points
  12. @PGia While it's very possible to create variables on the fly. I agree with Lee that it should not be a method to use, especially in the way you are wanting to use it. That being said, I wrote the following many years ago, but hardly have ever used it for anything. It accepts an assoc. list of strings representing variables and the corresponding values, then creates a variable for each with the value. The core of it is very simple (set (read "StrVar") value) ;|============================================================================== Function Name: (pjk-dynsetvar) Arguments: assoclst = List of cons; an assoc list on the format: (list (cons "<var name1>" <value1>) ... (cons "<Var namN>" <valueN>)) Usage: (pjk-dynsetvar <Assoc. List>) Ex: (pjk-dynsetvar (list (cons "Cenpt" (list 1.0 1.0 0.0)) (cons "Radius" 0.25))) Returns: The results of the read list. You can verify the variables with the ! prefix: Command line Example: Command: (pjk-dynsetvar (list (cons "Cenpt" (list 1.0 1.0 0.0)) (cons "Radius" 0.25))) ((1.0 1.0 0.0) 0.25) Command: !Cenpt (1.0 1.0 0.0) Command: !Radius 0.25 Description: This function dynamically sets AutoLISP variables based on an association list of strings and values. The string keys represent the names of the variables that the values will be assigned to. ================================================================================|; (defun pjk-DynSetVar (assoclst) (mapcar (function (lambda (x)(set (read (car x)) (cdr x)))) assoclst) ) ;; End Function (pjk-dynsetvar)
    2 points
  13. It seems it's not placing CENTERMARKS in Mechanical, I haven't tested other verticals from the toolset, it does use my fallback CrossHairs, though. I may not bother getting CENTERMARK to work in verticals unless someone else is interested, I would use the LISP in AutoCAD anyway, but I will do some testing on Mechanical/Architectural drawings in AutoCAD when I have time. Speaking of time, does anyone have a LISP or something that can give me a 30+ hour day, maybe @rlx I'll try to check this latest version in AutoCAD 2000i this weekend.
    2 points
  14. @Steven P A couple of suggestions (defun MakeDriveList ( / replace with (if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already (setq drivelist (ah:butts 1 "V" '("Please choose" "C:" "D:" "E:" "F:"))) "(setq GetFolderDcl (load_dialog "GetFolder"))" I use the write dcl to lisp by RLX so dcl code can live in the master lisp, then only one file. You may be able to use powershell to dump out the correct drives including network drives to a file and read that with lisp, done via a (startapp c:\path\drives.bat) powershell Get-PSDrive -PSProvider FileSystem | Out-File -FilePath "D:\acadtemp\drives_list.txt" exit Convert dcl 2 lisp rlx.lsp Multi radio buttons.lsp
    2 points
  15. and yet here's another version that should run in LT pl_GetDir.lsp
    2 points
  16. Hi all, I've been looking into finding a way to change annotative text multileaders from yes to no via lisp and i've had no luck. does anybody know if its possible? not sure why its so difficult. i want to be able to remove (not to delete just change from yes to no) all objects with annotative text from a drawing including nested objects. (im running full version autocad 2026)
    1 point
  17. Adding to @Nikon excellent explanation of the ssget function, also include the option to filter out locked layers "_:L" else the routine would crash out. (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER"))))
    1 point
  18. To select multiple objects, use **`ssget`** instead of `entsel`, and then apply `setpropertyvalue` to each selected object in a loop. Select several objects using a frame, or one at a time. For all selected objects, the **Annotative** property will change to **No**. The filter allows you to select: `TEXT`, `MTEXT', `DIMENSION`, `MULTILEADER` **Objects are not deleted or recreated.** Only the `Annotative` property is changed. ; "Annotative" 0 /No/ (defun c:NoAnno (/ ss i) ; AI ;; (if (setq ss (ssget '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER")))) (if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER")))) ; remark of Paul Li (progn (setq i 0) (repeat (sslength ss) (setpropertyvalue (ssname ss i) "Annotative" 0) (setq i (1+ i)) ) (princ (strcat "\nProcessed objects: " (itoa i))) ) ) (princ) ) ; "Annotative" 1 /Yes/ (defun c:YesAnno (/ ss i) ; AI ;; (if (setq ss (ssget '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER")))) (if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER")))) ; remark of Paul Li (progn (setq i 0) (repeat (sslength ss) (setpropertyvalue (ssname ss i) "Annotative" 1) (setq i (1+ i)) ) (princ (strcat "\nProcessed objects: " (itoa i))) ) ) (princ) ) ;;; Remove/Add Annotative property to objects [No/Yes] (default No) ;;; Supported objects: TEXT, MTEXT, DIMENSION, MULTILEADER (defun c:SetAnno (/ ss i ans val) ;; Prompt the user, default is No (initget "No Yes") (setq ans (getkword "\nRemove/Add Annotative property to objects [No/Yes] <No>: ")) (if (not ans) (setq ans "No")) ; if Enter pressed — use No (setq val (if (= ans "Yes") 1 0)) ; Yes = 1, No = 0 ;; (if (setq ss (ssget '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER")))) (if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER")))) ; remark of Paul Li (progn (setq i 0) (repeat (sslength ss) (setpropertyvalue (ssname ss i) "Annotative" val) (setq i (1+ i)) ) (princ (strcat "\nProcessed objects: " (itoa i) " | Annotative = " ans)) ) (princ "\nNo objects selected.") ) (princ) )
    1 point
  19. As programmable as AutoCAD can be, Excel (and LibreOffice Calc, et. al.) IMO handle Text, MText, Attributes, etc. much better.
    1 point
  20. I forgot about this. Att2Text.lsp converts attributes in a block to text outside the block, removes the attribute from the block and Att2TxtBlk.lsp converts attributes in a block to text outside the block, leaves the attribute in the block. Att2Text.lsp Att2TxtBlk.lsp
    1 point
  21. Maybe yes, that would work, and in excel just combine any attributes that need to be - formula for that I guess if doing many sheets
    1 point
  22. Technically that's an Express Tool, there used to be several other similar LISPs around as well, there might be one that can do as you wish. In the meantime, just type Multiple, when prompted for the command enter MOCORO, it will stay active after you exit.
    1 point
  23. The MOCORO command is pretty useful at times. It combines the move, copy, rotate and scale commands into one. Handy if you want to use two or more of these commands on a single object. It would be better if you could change your selection without breaking the command or if it had a reference option for rotate and scale.
    1 point
  24. Straight out of ChatGPT providing both No & Yes versions MldAnoY.lsp MldAnoN.lsp
    1 point
  25. Did something similar for vehicle driveway checking, just a maybe make the box like 2mm smaller than true size and position and rotate, use intersectwith to see if the box and walls touch you will get nil if they dont.touch. Say stop when get points.
    1 point
  26. This was created by Copilot, limited testing. and only sorts on single item. (defun BubblePass (lst / a b) (cond ((or (null lst) (null (cdr lst))) lst) ((> (car lst) (cadr lst)) (cons (cadr lst) (BubblePass (cons (car lst) (cddr lst))))) (t (cons (car lst) (BubblePass (cdr lst)))) ) ) (defun BubbleSort (lst / i) (repeat (length lst) (setq lst (BubblePass lst)) ) lst ) Asked about sort on 1st 2 items in list (defun QSORT2 (lst / pivot) (defun _less (a b) (or (< (car a) (car b)) (and (= (car a) (car b)) (< (cadr a) (cadr b))))) (if (cdr lst) (progn (setq pivot (car lst)) (append (QSORT2 (vl-remove-if-not '(lambda (x) (_less x pivot)) (cdr lst))) (list pivot) (QSORT2 (vl-remove-if-not '(lambda (x) (not (_less x pivot))) (cdr lst))) ) ) lst ) ) Limited testing.
    1 point
  27. @Discus84 Your question reminded me of the time my son asked me if I could determine if the couch he was planning to buy would fit in the frieght elevator of his aprtment building. There are several way to solove this problem. 1. Make multiple copies of the red box at different angles and then position them with object snap against the walls and floor. 2. Use the paramteric feature of AutoCAD to create and constrain the wall and the box. The following image shows only the angle contraint of the box. Tangency to the wall and floor is made via a dimensional contraint. Here's the result of changing the box angle. The following shows the dimensional and geometric constraints. Note, d3 constrains the box to be flush with the back wall and d9 with the floor. You can edit the dimensions in the attached file to meet yout requirements. box fit.dwg
    1 point
  28. It mentions this in the help file that "Duplicate elements may be eliminated from the list."
    1 point
  29. Great question! This is a classic challenge when working with meshes in AutoCAD. When you increase the smoothness level globally, it acts like a blanket smoothing filter and ruins hard edges. To keep sharp features intact, here are a few approaches depending on the model: Creasing Edges (MESHSMOOTHCREASE): Before increasing smoothness, you can apply creases to specific edges or vertices. This tells AutoCAD to hold those edges sharp even at higher subdivision levels. Selective Refinement: Instead of cranking up the global smoothness for the whole object, try refining only specific faces or sub-objects where smooth transitions are actually needed, leaving critical mechanical features alone. Hybrid Modeling: If precise dimensions and sharp intersections are critical (like for manufacturing components), I usually avoid heavy mesh editing and stick to solid modeling, or convert the final clean shape back to solids using CONVTOSOLID once the organic parts are done. How complex is the geometry you're working on? Are you dealing with mechanical parts or more of an architectural/organic shape?
    1 point
  30. @Danielm103 Interesting. I didn't know about those functions or that a parallel namespace existed. I'll look into that. Maybe it will minimize the drawbacks of using dynamic variables. @BIGAL Suppose we're dealing with elements that are scattered over a large area and you need to sort only a part of them and get a list. It might seem that the vl-sort function could be useful for this; however, it has a drawback: sometimes it deletes repeated elements from the list based on the filters. So I'm trying to do it without using vl-sort. Note: There are some objects that match exactly in location with others. @mhupp: Dictionary? What dictionary?
    1 point
  31. I Agree with Lee I'm interested in what your actually doing. take this for example. different approaches lisps that have a large range of run times. all basically doing the same thing. mine still took over a min to run, but ronjonp came in with 4.07 sec. theirs built an main list processed that list into smaller lists. once processed removed the items from each lists. (speeds up search)
    1 point
  32. Here is my latest zoom .9x in all layouts. I hadn't noticed the OP posted a .dwg, so i ran my Viewport Border into Model code on it. Is the result you wanted? ====================================== AutoVPBrdr REPORT ====================================== True layout viewports: 4 Viewport layer assignments: 4 Layer assignment failures: 0 Modelspace borders created: 3 Viewports skipped: 1 -------------------------------------- Layer: Viewport Color: 45 Plot: OFF ====================================== ZE_Z9XP_1.1.lsp
    1 point
  33. Frustratingly I think it has a couple of VLAX functions but not all of them - for LT I'd be finding another way if possible (in my example above bypassing the functionality completely)
    1 point
  34. @BIGAL you're correct...in fact functions attempting to access 3rd party apps like Excel are all not supported: https://help.autodesk.com/view/ACDLT/2024/ENU/?guid=GUID-037BF4D4-755E-4A5C-8136-80E85CCEDF3E
    1 point
  35. The other important one missing is Vlax-get-application it allows you to talk to Excel via lisp.
    1 point
  36. @indiancad here's a thread that you might find interesting regarding twist relative to a spline. Note that the first derivative of a curve is a vector tangent to the spline at a specifed point on the spline. The second derivative is a vector thet is the direction and magnitude of the change in the tangent vector at a point. The cross product of these two vetors, also know as the transverse vector, point to the instantaneous center of curvature for the curve at a specfied point along a curve. I wrote the following program to display graphically the radius of curvature (the ends of the generated lines are the center of curvature) or the curvature of a spline (short lines indicate almost flat segments of a spline). Try the program on a spline and answer Yes when prompted. (defun C:DOCL (/ path inc n osm par der1 der2 curva p perp normv p2 sf curveType ans) ; = Degree Of Curvature - Lines ; Creates curvature lines or radius-of-curvature lines ; normal to a spline. ; LRM 8/18/2022 edited to place curvature vectors outside (setq path (car (entsel)) inc (/ (vlax-curve-getEndParam path) 100) n 0 osm (getvar 'osmode) ) (setvar 'osmode 0) (setvar "cmdecho" 0) (initget "y n") (setq ans (getkword "Do you want radius-of-curvature instead of curvature? [y/n] <n>: ")) (if (= ans "y") (setq curveType 1) (setq curveType 2 sf (getdist "Enter scale factor.") ) ) (repeat 100 (setq par (* inc n)) (setq der1 (vlax-curve-getfirstDeriv path par) der2 (vlax-curve-getSecondDeriv path par) ) ; calculate curvature at point par (setq d (distance '(0 0 0) (cross der1 der2))) (if (> (abs d) 1.0e-15) (progn (setq curva (/ (expt (distance '(0 0 0) der1) 3) d)) (if (= curveType 2) (setq curva (* -1. (* sf (/ 1. curva)))) ) (princ "\n") (princ n) (princ " curvature = ") (princ curva) (setq p (vlax-curve-getPointAtParam path par) perp (unitv (cross der1 (cross der2 der1))) normv (mapcar '* perp (list curva curva curva)) p2 (mapcar '+ p normv) ) (command "_.line" p p2 "") ) ; end progn ) (setq n (1+ n)) ) (setvar 'osmode osm) (setvar "cmdecho" 1) (princ) ) ;;; Compute the cross product of 2 vectors a and b (defun cross (a b / crs) (setq crs (list (- (* (nth 1 a) (nth 2 b)) (* (nth 1 b) (nth 2 a)) ) (- (* (nth 0 b) (nth 2 a)) (* (nth 0 a) (nth 2 b)) ) (- (* (nth 0 a) (nth 1 b)) (* (nth 0 b) (nth 1 a)) ) ) ;end list ) ;end setq c ) ;end cross (defun unitV ( v / d) (setq d (distance '(0 0 0) v) d (mapcar '/ v (list d d d)))) blocks_on_spline.lsp spline curvature.lsp
    1 point
  37. FYI: LT 2024+ does support vlax functions but not vlax-create-object
    1 point
  38. Besides checking the related settings, I have had to rotate and position the shape as well, though most of my SWEEP experience is with piping, so no worries if a circle twists.
    1 point
  39. Here's another without command calls: (defun c:zal (/ a d c tabs) ;; RJP » 2020-07-08 (setq c (getvar 'ctab)) (vlax-for x (vla-get-layouts (setq d (vla-get-activedocument (setq a (vlax-get-acad-object))))) (setq tabs (cons (list (vla-get-name x) (vla-get-taborder x)) tabs)) ) ;; The sort makes sure that the tabs step left to right (foreach x (cdr (vl-sort tabs '(lambda (r j) (< (cadr r) (cadr j))))) (setvar 'ctab (car x)) (vlax-put d 'mspace 0) (vla-zoomextents a) ) (setvar 'ctab c) (princ) )
    1 point
  40. Here is how the codes line up between all the view ports:
    1 point
  41. No it is more when we go from title block version 7 to version 9.2... with the same block name... for example, title attributes go from 5 down to 4 lines and they rename drawing number attribute DwgNo to Drawing - just updating the block doesn't quite capture it all... so (lazy CAD) - burst usually works well. I think I have a LISP global updates of all the same block in a drawing - think it is one of Lee Macs - but most of our drawings are 1 sheet per file so another of Lees works for multiple sheets over may drawings.
    1 point
  42. @Steven P not sure if this is what you mean, but I have pick attribute in say title block in a layout and it will copy that attribute value into the correct attribute in all blocks of that name, I think also a do multiple atts, handy when say you change a project description, updates all layouts etc.
    1 point
  43. I am a big fan of the "Layers 2" Toolbar, where I first encountered LAYWALK. It was much more useful to me when my drawings had appreciably less than the thousands of layers which have become the norm. I really like LAYISO (LI) and LAYUNISO (LU). I prefer unisolated layers to be turned off, rather than dimmed. I am a huge advocate for setting up and using QUICK PROPERTIES. The modest amount of time invested, customizing it to your personal preferences will pay huge rewards henceforth.
    1 point
  44. I would place MATCHPROP on the very top. I use that command so much is almost like 2nd nature to click on that button on the Quick Access Bar. Others commands I use quite often are: LAYMCUR - makes selected object's layer current LAYLCK/LAYULK - selected object's layer to be locked/unlocked DRAWORDER - Sends selected object to back/front Also I tend to keep the following palettes opened/docked/auto-hidden: PROPERTIES - Object Properties LAYER - Layer Properties Manager XREF - External References
    1 point
  45. I wrote this program for my own needs. It was created very quickly and hastily because I needed to update the title blocks in over 40 *.dwg files. When run from as command, it asks for one or several title blocks to retrieve the block names and then exports all blocks on the layouts to a CSV file in a format accepted by the "Lee - update title block" command. The program can also be run as a script where the block name is specified, allowing the export of title blocks in multiple DWG files. The program is capable of exporting data from blocks with different names and attributes (at least, that is the intention, though I admit I tested it only once on a single project). The CSV file is exported to the folder where the given DWG file is located. The file name is utb_data.csv. I probably won't improve the program, but maybe someone will find it useful or want to clean it up. Function: (defun c:utbdump nil (dump_blocks_for_utb nil)) ; (dump_blocks_for_utb "title_block_v0*") (defun dump_blocks_for_utb (block_names / ss blk_names atts ss_export lst header) ; (setq xref_lst (cd:SYS_CollList "BLOCK" 32)) (if block_names (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 block_names) (cons 67 1) ) ) ) (progn (princ "\nSelect blocks to get names ") (setq ss (ssget (list (cons 0 "INSERT")) ) ) ) ) (if ss (progn (setq blk_names (mapcar '(lambda (%) (cdr (assoc 2 (entget %))) ) (cd:SSX_Convert ss 0) ) ) (setq atts (LM:Unique (apply 'append (mapcar '(lambda (%) (mapcar 'car (cd:BLK_GetAttsVLA %)) ) (cd:SSX_Convert ss 1) ) ) ) ) (setq ss_export (ssget "_X" (list (cons 0 "INSERT") (cons 2 (gtc:BLK_SsgetFilterNames blk_names) ) (cons 67 1) ) ) ) (setq lst (mapcar (function (lambda (%) (append (list (strcat (getvar 'dwgprefix) (getvar 'dwgname) ) (cdr (assoc 410 (entget %))) (LM:effectivename %) ) (if atts (mapcar '(lambda (%att / att_val) (if (and (setq att_val (cd:BLK_GetAttValueVLA % %att ) ) (not (= att_val "")) ) (strcat "" att_val) "" ) ) atts ) ) ) ) ) (cd:SSX_Convert ss_export 0) ) ) (setq header (append (list "DWG" "Layout" "Block") (if atts atts ; (mapcar '(lambda (%) (strcat "'ATT_NAME: " %)) atts) ) ) ) (pz:SYS_WriteCSV (strcat (getvar 'dwgprefix) "utb_data.csv") (cons header lst) ) ) ) ) (defun pz:SYS_WriteCSV (Name Lst / old_csv old_header_row new_header_row union_header_row csv current_header data current_row res_list row_to_add ) (if (findfile Name) (progn (setq old_csv (LM:readcsv Name)) (setq old_header_row (car old_csv)) (setq new_header_row (car Lst)) (setq union_header_row (LM:ListUnion old_header_row new_header_row)) (foreach csv (list old_csv Lst) (setq current_header (car csv)) (setq data (cdr csv)) (foreach row data (setq current_row (mapcar (function (lambda (%1 %2) (cons %1 %2))) current_header row ) ) (setq row_to_add (mapcar (function (lambda (%att / att_val) (if ; (and (setq att_val (cdr (assoc %att current_row ) ) ) ; (not (= att_val "")) ; ) att_val "" ) ) ) union_header_row ) ) (setq res_list (cons row_to_add res_list)) ) ) (setq res_list (cons union_header_row (LM:Unique (reverse res_list)))) ) (setq res_list Lst) ) (LM:writecsv res_list Name) ) Essential Library Functions: ; =========================================================================================== ; ; Zmienia PICKSET na liste obiektow / Convert PICKSET to list of objects ; ; Ss [PICKSET] - zbior wskazan / selection sets ; ; Mode [INT] - typ zwracanych obiektow / type of returned objects ; ; 0 = ENAME, 1 = VLA-OBJECT, 2 = SAFEARRAY ; ; ------------------------------------------------------------------------------------------- ; ; (cd:SSX_Convert (ssget) 1) ; ; =========================================================================================== ; (defun cd:SSX_Convert (Ss Mode / n res) (if (and (member Mode (list 0 1 2)) (not (minusp (setq n (if Ss (1- (sslength Ss)) -1) ) ) ) ) (progn (while (>= n 0) (setq res (cons (if (zerop Mode) (ssname Ss n) (vlax-ename->vla-object (ssname Ss n)) ) res ) n (1- n) ) ) (if (= Mode 2) (vlax-safearray-fill (vlax-make-safearray 9 (cons 0 (1- (length res))) ) res ) res ) ) ) ) ;; Unique - Lee Mac ;; Returns a list with duplicate elements removed. (defun LM:Unique ( l / x r ) (while l (setq x (car l) l (vl-remove x (cdr l)) r (cons x r) ) ) (reverse r) ) ; =========================================================================================== ; ; Pobiera wartosci wszystkich atrybutow / Gets the values of all attributes ; ; Obj [VLA-Object] - obiekt VLA / VLA-Object ; ; ------------------------------------------------------------------------------------------- ; ; (cd:BLK_GetAttsVLA (vlax-ename->vla-object (car (entsel)))) ; ; =========================================================================================== ; (defun cd:BLK_GetAttsVLA (Obj) (mapcar (function (lambda (%) (cons (vla-get-TagString %) (vla-get-TextString %) ) ) ) (vlax-invoke Obj (quote GetAttributes)) ) ) ;; @d - [Str/List] ;; Str - block name - support for wcmatch ;; List - list of block names (defun gtc:BLK_SsgetFilterNames (@d / u) (if (= (type @d) 'LIST) (setq @d (cd:STR_ReParse (LM:Unique (mapcar '(lambda (%1) (cond ((and (wcmatch %1 "`**") (setq tmp (pz:BLK_GetDynBlockNames-S %1)) ) (strcase tmp) ) ((wcmatch %1 "`**") (strcase (strcat "`" %1)) ) (T (LM:escapewildcards (strcase %1)) ) ) ) @d ) ) "," ) ) ) ; (if (pz:FilterTabOrLst "BLOCK" @d) ; (if (setq u (jk:BLK_GetDynBlockNames-S @d)) ; (strcat @d ",`" (cd:STR_ReParse u ",`")) ; @d ; ) ; nil ; ) (if (setq u (pz:BLK_GetDynBlockNames-S @d)) (strcat @d ",`" (cd:STR_ReParse u ",`")) @d ) ) ; =========================================================================================== ; ; Laczy liste lancuchow w lancuch z separatorem / ; ; Combines a list of strings in the string with the separator ; ; Lst [LIST] - lista lancuchow / list of strings ; ; Sep [STR] - separator / separator ; ; ------------------------------------------------------------------------------------------- ; ; (cd:STR_ReParse '("OLE2FRAME" "IMAGE" "HATCH") ",") ; ; =========================================================================================== ; (defun cd:STR_ReParse (Lst Sep / res) (setq res (car Lst)) (foreach % (cdr Lst) (setq res (strcat res Sep %)) ) res ) ;; Escape Wildcards - Lee Mac ;; Escapes wildcard special characters in a supplied string (defun LM:escapewildcards ( str ) (vl-list->string (apply 'append (mapcar '(lambda ( c ) (if (member c '(35 64 46 42 63 126 91 93 45 44)) (list 96 c) (list c) ) ) (vl-string->list str) ) ) ) ) ;; Effective Block Name - Lee Mac ;; obj - [obj] Block Reference vla object (defun LM:effectivename ( obj ) (if (= (type obj) 'ENAME) (setq obj (vlax-ename->vla-object obj)) ) (vlax-get-property obj (if (vlax-property-available-p obj 'effectivename) 'effectivename 'name ) ) ) ; =========================================================================================== ; ; Pobiera wartosc atrybutu / Gets the attribute value ; ; Obj [ENAME/VLA-Object] - entycja lub obiekt VLA / entity name or VLA-Object ; ; Tag [STR] - etykieta atrybutu / attribute tag ; ; ------------------------------------------------------------------------------------------- ; ; (cd:BLK_GetAttValueVLA (car (entsel)) "VIEW_NUMBER") ; ; =========================================================================================== ; (defun cd:BLK_GetAttValueVLA (Obj Tag) (if (= (type Obj) (quote ENAME)) (setq Obj (vlax-ename->vla-object Obj)) ) (vl-some (function (lambda (%) (if (eq (strcase tag) (strcase (vla-get-TagString %))) (vla-get-TextString %) ) ) ) (vlax-invoke Obj (quote GetAttributes)) ) ) ;; Write CSV - Lee Mac ;; Writes a matrix list of cell values to a CSV file. ;; lst - [lst] list of lists, sublist is row of cell values ;; csv - [str] filename of CSV file to write ;; Returns T if successful, else nil ; (defun c:test ( / fn in lst ss ) ; (if ; (and ; (setq ss (ssget '((0 . "POINT")))) ; (setq fn (getfiled "Create Output File" "" "csv" 1)) ; ) ; (progn ; (repeat (setq in (sslength ss)) ; (setq lst (cons (mapcar 'rtos (cdr (assoc 10 (entget (ssname ss (setq in (1- in))))))) lst)) ; ) ; (if (LM:WriteCSV (reverse lst) fn) ; (startapp "explorer" fn) ; ) ; ) ; ) ; (princ) ; ) (defun LM:writecsv ( lst csv / des sep ) (if (setq des (open csv "w")) (progn (setq sep (cond ((vl-registry-read "HKEY_CURRENT_USER\\Control Panel\\International" "sList")) (","))) (foreach row lst (write-line (LM:lst->csv row sep) des)) (close des) t ) ) ) ;; List -> CSV - Lee Mac ;; Concatenates a row of cell values to be written to a CSV file. ;; lst - [lst] list containing row of CSV cell values ;; sep - [str] CSV separator token (defun LM:lst->csv ( lst sep ) (if (cdr lst) (strcat (LM:csv-addquotes (car lst) sep) sep (LM:lst->csv (cdr lst) sep)) (LM:csv-addquotes (car lst) sep) ) ) (defun LM:csv-addquotes ( str sep / pos ) (cond ( (wcmatch str (strcat "*[`" sep "\"]*")) (setq pos 0) (while (setq pos (vl-string-position 34 str pos)) (setq str (vl-string-subst "\"\"" "\"" str pos) pos (+ pos 2) ) ) (strcat "\"" str "\"") ) ( str ) ) )
    1 point
  46. Just added this to the link from SLW210, below modified to select many dimensions. Note the entity to dimension to are lines just now, should work with other entities, just change that line, (defun c:reass ( / DimEnt MyDim Pta Ptb EndA EndB EndA_Lines EndB_Lines) (if (setq ss (ssget '((0 . "DIMENSION")) )) ; select dimensions (repeat (setq i (sslength ss)) ; loop through selection set (setq DimEnt (ssname ss (setq i (1- i)))) (command "_zoom" "O" DimEnt "") (setq MyDim (entget DimEnt)) (setq Pta (cdr (assoc 13 MyDim))) (setq Ptb (cdr (assoc 14 MyDim))) (setq EndA_Lines (ssget "_C" (mapcar '+ Pta (mapcar '/ Pta '(1000 1000 1000))) (mapcar '- Pta (mapcar '/ Pta '(1000 1000 1000))) '((0 . "LINE")) )) ; select entity close to end of dimension line (setq EndB_Lines (ssget "_C" (mapcar '+ Ptb (mapcar '/ Pta '(1000 1000 1000))) (mapcar '- Ptb (mapcar '/ Pta '(1000 1000 1000))) '((0 . "LINE")) )) ; select entity close to end of dimension line ; (command "dimreassociate" DimEnt "" "end" Pta "end" Ptb) (if EndA_Lines (command "dimreassociate" DimEnt "" "end" Pta "")) (if EndB_Lines (command "dimreassociate" DimEnt "" "end" "" "end" Ptb )) (command "_zoom" "previous") ) ; end repeat ) ; end if (princ) ; end quietly )
    1 point
×
×
  • Create New...