Jump to content

Leaderboard

  1. GLAVCVS

    GLAVCVS

    Community Member


    • Points

      13

    • Posts

      844


  2. rlx

    rlx

    Trusted Member


    • Points

      11

    • Posts

      2,247


  3. BIGAL

    BIGAL

    Trusted Member


    • Points

      7

    • Posts

      19,935


  4. Lee Mac

    Lee Mac

    Trusted Member


    • Points

      7

    • Posts

      21,090


Popular Content

Showing content with the highest reputation since 01/01/2026 in Posts

  1. Their IT department even has a slogan (and I'm not kidding here) : You name it , we block it
    4 points
  2. The reason I clean the drawing is I once wrote a program to generate instrument loop diagrams from an excel file. I found the most stable and easy way was not to use a script but stay in the current drawing and from there save(as) each loop. I also made use from templates and also had the option to update the drawing in stead of generating the entire drawing. But at some time some templates had been given an update to a block definition and to be certain the latest version was used I had to make sure the old block was purged. Overkill , some times yes , but in my case it worked as it should. In this case , dxfin , probably overkill , but it doesn't hurt either. I tested it on Bricad 22 and the dwg extension was no problem, it worked as it should. The recommendation from the annoying paperclip oh , sorry , AI its called these days , to pimp the filename and use vla-saveas is not wrong though. Just didn't need it on my computer. Had it gave me an error I would have fixed it but it worked right from the start for me.
    4 points
  3. This version should work in all cases, regardless of the complexity of the polygons ;******************* p o r d e s i a r g o ******************** ;************************ G L A V C V S ************************* ;************************** F E C I T *************************** (defun c:RectOffBatch (/ selset dist i ent pts offsetpt a70 es l le p1 p2 o sDir) (defun sDir (le i? / p1 p2 p ar ang ab dir tl) (foreach l le (if (and (= (car l) 10) (setq p (cdr l))) (progn (if p2 (if p1 (setq dir (cond ((< (abs (setq ang (- (setq ar (angle p1 p2)) (setq ab (angle p2 p))))) PI) ang) (T (if (<= ar PI) (+ ar (- (* 2 PI) ab)) (- (- ar (* 2 PI)) ab))) ) ) ) ) (if dir (setq tl (+ (if tl tl 0) dir))) (setq p1 p2 p2 p dir nil) ) ) ) (if (minusp tl) (if i? + -) (if i? - +)) ) (prompt "\nSelect rectangles (polylines): ") (setq selset (ssget '((0 . "*POLYLINE")))) (vl-cmdf "_.CONVERTPOLY" "_Light" selset "") (if selset (if (setq i -1 dist (getdist "\nEnter the offset distance: ")) (repeat (sslength selset) (setq ent (ssname selset (setq i (1+ i)))) (setq o (sDir (setq le (entget ent)) nil)); <-- CHANGE 'nil' TO 'T' FOR OFFSET INWARD TOWARD INTERIOR OF THE POLYGONS (if (= (rem (cdr (setq a70 (assoc 70 le))) 2) 0) (entmod (subst (cons 70 (+ (cdr a70) 1)) a70 le))) (setq pr (vlax-curve-getPointAtParam ent 0.5)) (setq offsetpt (polar pr (o (angle (vlax-curve-getPointAtParam ent 0) pr) (/ PI 2.)) 0.1)) (command "_.OFFSET" dist ent offsetpt "") ) ) ) (princ) )
    3 points
  4. I'll this topic a "wrap" Thanks to all here! rlx: I also have worked at my last company of fifteen years within a very locked down IT environment. Here and now, I am free! One caveat here is that there are limitations in acquiring additional Microsoft tools i.e., Power Platform tools, etc. due to the complexity introduced from being a client of an widely known commercial web hosting service. Happy, happy, happy! Clint
    3 points
  5. Use this and simply switch: *dist* (- *dist*) To: (- *dist*) *dist*
    3 points
  6. Just use: (command "_.OFFSET" dist ent "_non" offsetpt "") And you no longer need to worry about OSMODE.
    2 points
  7. You would still need Visual Studio or similar and packages installed. Even for Visual Studio Code and LISP, I get PowerShell errors due to IT blocking it as well as the need to download the extension. Main issue is just lazy IT departments not wanting to due proper security, every issue I have had a work shows "improper server configuration" and/or "improper firewall configuration" when searching the issue. Anyone using Autodesk products (maybe other programs as well) has to manually override the proxy server on each restart of their computer or we have licensing issues. I had to to do all of the leg work on getting that issue resolved. Unfortunately that's just how many IT "professionals" are trained, "when in doubt, block it out". I normally don't have issues getting programs installed, just usually they are in no hurry to get it done. Autodesk is partly to blame, should be a better way to get apps, add-ons, etc. than needing an IT install. Even Microsoft, why do I need to update Windows and MS Office tools separately and need IT to allow use of PowerShell? To be honest though, I am just the AutoCAD guy, so they don't understand how programming with other tools is relevant.
    2 points
  8. If you want to change the offset direction, you just need to change the 'i?' parameter used to call 'sDir' from 'nil' to 'T' (as indicated in the code comment). Nikon2.mp4 PS: The video shows the execution of the code with 'i?' set to 'T'.
    2 points
  9. I tested the code on your drawing and it works correctly. Perhaps you didn't use it correctly. Nikon1.mp4
    2 points
  10. Yikes! Working with your arms tied.. No way I could work effectively without my tools, I would at least need autohotkey. Last company I worked for, I automated their whole system, mostly because I was lazy and I wanted to eat donuts all day. AutoCAD ships with .NET, nothing to install, I would be rolling some goodies for sure. “We At ACME corporation stifle innovation by making everyone think inside the box”
    2 points
  11. For most things I do this is my default option, rarely need to do much other than that and if I do, drag and drop.
    2 points
  12. There's an app for that: https://apps.autodesk.com/ACD/en/Detail/Index?id=3434696327413675915&appLang=en&os=Win32_64
    2 points
  13. new to Bricad but this seems to work : (defun c:DxfToDwg ( / actDoc dxf-folder dxf-list ) (setq actDoc (vla-get-activedocument (vlax-get-acad-object))) (vl-load-com) (cond ((not (setq dxf-folder (_getfolder "Select folder with dxf files"))) (princ "\nNo folder selected")) ((not (vl-consp (setq dxf-list (_getfiles dxf-folder "*.dxf")))) (princ (strcat "\nNo dxf files in folder " dxf-folder))) (t (command ".undo" "mark")(setvar "expert" 2) (foreach dxf dxf-list (command ".erase" "all" "") (vla-purgeall actDoc) (vl-cmdf "_.dxfin" dxf) (vla-ZoomExtents (vlax-get-acad-object)) (command ".save" (strcat (vl-filename-directory dxf) "\\" (vl-filename-base dxf))) ) (command ".undo" "back") ) ) (princ) ) ; generic getfolder routine with possibility to create a new subfolder (_getfolder "select path") (defun _getfolder ( m / f s) (if (and (setq s (vlax-create-object "Shell.Application")) (setq f (vlax-invoke s 'browseforfolder 0 m 65536 "")))(setq f (vlax-get-property (vlax-get-property f 'self) 'path)) (setq f nil))(vl-catch-all-apply 'vlax-release-object (list s)) (if f (vl-string-translate "\\" "/" f))) (defun void (x) (or (eq x nil) (and (listp x)(not (vl-consp x))) (and (eq 'STR (type x)) (eq "" (vl-string-trim " \t\r\n" x))))) (defun _getfiles ( fol ext / lst) (cond ((or (void fol) (not (vl-file-directory-p fol))) (princ (strcat "\nInvalid folder :" (vl-princ-to-string fol)))) (t (if (vl-consp (setq lst (vl-directory-files fol ext 1))) (setq lst (mapcar '(lambda (x)(strcat fol "/" x)) lst)))) ) lst )
    2 points
  14. @Danielm103 ""with mtext, you have to use a fixed width font" I agree, Monotxt.sHx I think was what I used. monotxt_.ttf EXTRA FONTS A-Z.txt Banner heading3.lsp
    2 points
  15. Most of the members here have real jobs as well and provide help as their own busy schedules allow. I do not believe anyone was being rude, just nudging you along to do a little work for yourself.
    2 points
  16. A simple script made with notepad. Open dwg1.dxf qsave dwg1 close Open dwg2.dxf qsave dwg2 close Open dwg3.dxf qsave dwg3 close Open dwg3.dxf qsave dwg3 close The dwg1 would be like "C:\\mydxfiles\\project123\\dwg1" There are various ways to make a list of dwg names, how many are we talking about ?
    2 points
  17. This was my 'Offset Inside' program: ;; Offset Inside - Lee Mac - www.lee-mac.com ;; Offsets a set of objects by a specified distance to the inside. (defun c:OffInside ( / acsel pos ) (if (and (setq *dist* (cond ( (getdist (strcat "\nOffset Distance" (if *dist* (strcat " <" (rtos *dist*) ">: ") ": ") ) ) ) ( *dist* ) ) ) (ssget '( (-4 . "<OR") (0 . "CIRCLE,ARC,ELLIPSE") (-4 . "<AND") (0 . "LWPOLYLINE,SPLINE") (-4 . "&=") (70 . 1) (-4 . "AND>") (-4 . "<AND") (0 . "POLYLINE") (-4 . "&=") (70 . 1) (-4 . "<NOT") (-4 . "&") (70 . 120) (-4 . "NOT>") (-4 . "AND>") (-4 . "OR>") ) ) ) (progn (vlax-for obj (setq acsel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)) ) ) (vl-catch-all-apply 'vla-offset (list obj (if (and (setq pos (vl-position (vla-get-objectname obj) '("AcDbPolyline" "AcDb2dPolyline"))) (LM:ListClockwise-p (LM:GroupByNum (vlax-get obj 'coordinates) (+ pos 2))) ) *dist* (- *dist*) ) ) ) ) (vla-delete acsel) ) ) (princ) ) ;; List Clockwise-p - Lee Mac ;; Returns T if the point list is clockwise oriented (defun LM:ListClockwise-p ( lst ) (minusp (apply '+ (mapcar (function (lambda ( a b ) (- (* (car b) (cadr a)) (* (car a) (cadr b))) ) ) lst (cons (last lst) lst) ) ) ) ) ;; Group by Number - Lee Mac ;; Groups a list into a list of lists, each of length 'n' (defun LM:GroupByNum ( l n / r) (if l (cons (reverse (repeat n (setq r (cons (car l) r) l (cdr l)) r)) (LM:GroupByNum l n) ) ) ) (vl-load-com) (princ)
    2 points
  18. I have a drawing with multiple rotated dimensions and some are quite small resulting in text being offset to the leader. I was wondering if there is an easy way to change all the text box components of the dimensions to fit the actual size of the text so that it isn't so offset from the leader without exploding all the dimensions. I've included some snap shots below for reference. There are quite a few in the file so I want to try and avoid having to do them manually one by one. Any help would be greatly appreciated. Regards, Ryan
    1 point
  19. You are correct, need the .NET SDK, and Extensions to build modules with Visual Studio Code. It’s been a while since I’ve done .NET, I think version 4 had the compiler, you could build with notepad and the command line ugh BTW, I’ve had companies reach out to me to support zero-install Python packages for AutoCAD. They wanted to validate the modules, and block PIP. Basically it’s: 1, Grab Python embedded package from the Python site, it’s a minimal, portable zipped interpreter for Windows. 2, add the most commonly used packages, pyrx, pyopenxl, pypdf, genre specific tools, like shapely, or gdal 3, deploy it as a .bundle. I've been meaning to write something about this, lazy i guess lol
    1 point
  20. Add this code below '(command " rectangle"... ', load it, and try running the code again (if (not (tblsearch "block" roomName)) (command "_block" roomName (setq pt (list (min (car fc) (car fc)) (min (cadr fc) (cadr fc)))) (setq cj (ssadd (entlast))) "") (princ (strcat "\n" roomName " already exist...")) ) (command "_.insert" roomName pt "" "" "")
    1 point
  21. That's definitely the best option. Thank you, @Lee Mac
    1 point
  22. I forgot to mention that: I haven't done anything with 'osmode' because I think it's convenient to manage it from the F3 key at runtime: you can activate or deactivate it during command execution by pressing F3.
    1 point
  23. So that it only offsets outwards, for example, like this (defun c:RectOffBatch (/ selset dist i ent pts offsetpt a70 es l le p1 p2 a midP) (prompt "\nSelect rectangles (polylines): ") (setq selset (ssget '((0 . "*POLYLINE")))) (vl-cmdf "_.CONVERTPOLY" "_Light" selset "") (if selset (progn (setq dist (getdist "\nEnter the offset distance: ") i 0) (repeat (sslength selset) (setq ent (ssname selset i)) (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (setq le (entget ent))))) (if (= (rem (cdr (setq a70 (assoc 70 le))) 2) 0) (entmod (subst (cons 70 (+ (cdr a70) 1)) a70 le))) (setq midP (mapcar '(lambda(v) (/ v (length pts))) (apply 'mapcar (cons '+ pts)))) (setq offsetpt (polar (car pts) (angle midP (car pts)) 0.01)) (command "_.OFFSET" dist ent offsetpt "") (setq i (1+ i)) ) ) ) (princ) )
    1 point
  24. As I said I did some testing about method, just get your closed plines, then check there CW or CCW direction and change if needed. Then use (getvar 'extmax) as offset point.In code below I use pedit "R" as the Reverse command is not available in Bricscad. CCW is offset out for a positive value using VLA-Offset. ; Checking if pline is CW or CCW and set to CCW ; Orignal idea by Kent Cooper, 1 August 2018 Offsetinorout.lsp ; By Alan H July 2020 (defun AH:chkcwccw (ent / objnew area1 area2 obj minpoint maxpoint) (setq obj (vlax-ename->vla-object ent)) (vla-GetBoundingBox obj 'minpoint 'maxpoint) (setq pointmin (vlax-safearray->list minpoint)) (setq pointmax (vlax-safearray->list maxpoint)) (setq dist (/ (distance pointmin pointmax) 20.0)) (vla-offset obj dist) (setq objnew (vlax-ename->vla-object (entlast))) (setq area1 (vlax-get objnew 'Area)) (vla-delete objnew) (vla-offset obj (- dist)) (setq objnew (vlax-ename->vla-object (entlast))) (setq area2 (vlax-get objnew 'Area)) (vla-delete objnew) (if (> area1 area2) (command "Pedit" ent "R" "") ) (princ) )
    1 point
  25. (70 . 1) or (70 . 128) will filter a selection set for closed polyline - (70 . 1) is usually enough
    1 point
  26. PS: 2D polylines do not support offset, so they need to be converted first. I haven't tested it extensively, but it should work for what you need.
    1 point
  27. If the polygons aren't too irregular, using your own code, maybe this... (defun c:RectOffBatch (/ selset dist i ent pts maxpt offsetpt a70 es l le p1 p2 a) (prompt "\nSelect rectangles (polylines): ") (setq selset (ssget '((0 . "*POLYLINE")))) (vl-cmdf "_.CONVERTPOLY" "_Light" selset "") (if selset (progn (setq dist (getreal "\nEnter the offset distance or ENTER to indicate on screen: ")) (setq p1 (getpoint "\nPick on/near one of the rectangles to be offset...")) (if (and (setq es (car (nentselp p1))) (= (wcmatch (cdr (assoc 0 (entget es))) "LWP*"))) (progn (setq p2 (getpoint p1 "\nPoint to get direction (or distance) to offset: ")) (if (not dist) (setq dist (distance p1 p2))) (setq l (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget es)))) (setq midP (mapcar '(lambda(v) (/ v (length l))) (apply 'mapcar (cons '+ l)))) (setq a (if (> (distance p1 midP) (distance p2 midP)) 0 PI) i 0 ) (repeat (sslength selset) (setq ent (ssname selset i)) (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (setq le (entget ent))))) (if (= (rem (cdr (setq a70 (assoc 70 le))) 2) 0) (entmod (subst (cons 70 (+ (cdr a70) 1)) a70 le))) (setq maxpt (list (apply 'max (mapcar 'car pts)) (apply 'max (mapcar 'cadr pts)))) (setq midP (mapcar '(lambda(v) (/ v (length pts))) (apply 'mapcar (cons '+ pts)))) (setq offsetpt (polar (car pts) (+ a (angle (car pts) midP)) 0.01)) (command "_.OFFSET" dist ent offsetpt "") (setq i (1+ i)) ) ) ) ) ) (princ) )
    1 point
  28. What they're talking about, I believe, is a matter of fairness. You ask for help but provide none in return. Most of us have other commitments, but we make time to teach and to help others. Not only that, learning a bit about AutoLISP will make your work easier and faster.
    1 point
  29. Even if I wanted to use a different language I wouldn't be able because at my work I'm unable to install any software that's not supplied in our software center , also certain extensions like *.bat are a big freaking no no so my dragon claws are tied in that respect. But I can get vl-some satisfaction however whenever I can create something that at first glance seems impossible to do and then come up with something that actually works.
    1 point
  30. What programming language to use ? There are so many, Lisp, Pascal, VBA, C##, now .NET, Python and of course the push product by Autodesk Dynamo but only on certain platforms. Yeah the macro record almost useless. As I have said before years ago macro record in a CAD program wrote VBA code. There is lisp2C from years ago that converted lisp code to C## code, hey Daniel what about convert lisp to Python ? The main advantage in lisp is the non compile, just run, I use code that is 30+ years old still works. Any compiled code every few years has to be recompiled to work as versions change. Dont forget how many years ago now Autodesk said VBA support would be removed, it's still there.
    1 point
  31. A couple of answers, as suggested, check is closed pline ie a rectang drawn CW or CCW then vla-offset will always go out for a CCW pline. You can do a check and reverse the pline if required. Or the simpler is (setq offsetpt (getvar 'extmax))
    1 point
  32. It’s more of, ‘pick the right tool for the right job’. In this case, ObjectARX, and by extension, Python, can provide a clean new drawing to import your DXFs into every time, whereas lisp may not. I don’t remember what all is stored in DXF, i.e. if there are things that are non-purgeable. An example is an existing text, dimension, or table style, that are named “Standard”. Nested references, Associated Styles (the text style for a dimension style). There may be user variables stored per drawing CLAYER, LTSCALE: So, using lisp DXFIN -> purge -> save on repeat may have subtle side effects. This may or may not be an issue for you
    1 point
  33. I would maybe use: (vla-Offset (vlax-ename->vla-object ent) dist) where dist can be positive to go one direction, negative to go the other. This direction might also depend on the direction that the rectangle was drawn - clockwise or anticlockwise. Could do them both directions and just delete the shorter line - a few more lines of code to add though, some thinking for the first full week of work in 2026, always a quiet week. I might also suggest a couple more filters to the selection set, if all rectangles are closed polylines (test: 70 is 1 or 128 - use bitand (search for this Lee Mac uses this often to test both at the same time)), or number of vertices being 3 (closed polyline) or 4 (open polyline) (test: 90 is 3 or 4)
    1 point
  34. According to the ARX docs using dxfIn While rlx’s version attempts to clean the drawing via vla-purgeall, I suppose there could be some items that are not purged? It’s not clear what happens in case of an existing dictionary or style. AI “AutoCAD typically handles conflicts by prioritizing the current drawing's definitions” I'm guessing that rlx’s version is safe enough though
    1 point
  35. if you can use Python import traceback from pyrx import Ap, Db def convert_dxf_to_dwg(dxf: str): dwg = dxf.replace(".dxf", ".dwg") db = Db.Database(False, True) db.dxfIn(dxf) db.saveAs(dwg) @Ap.Command() def dxftodwg(): try: for dxf in Ap.Application.listFilesInPath("E:\\FloorPlans", ".dxf"): convert_dxf_to_dwg(dxf) except Exception as err: traceback.print_exception(err)
    1 point
  36. .... so it isn't importing the DXF file? Still holidays till Monday so CAD is still off but what happens if you do the 'dxfin' line manually: (command "DXFIN" (strcat "-FolderName"- "\\" "-fileName-" ) "Default" "" "")
    1 point
  37. Lee's code allows the user to automatically generate polylines in modelspace representing the outline of a selected paperspace viewport, all viewports in the active paperspace layout, or all viewports found in all paperspace layouts. As long as the current layer is displayed in the Key Plan Viewport model space all those rectangles should display already. troggarf's code puts a copy of selected objects in paperspace.
    1 point
  38. Here's another enjoy CallOut_Imp.dwg
    1 point
  39. Even i have a real job. I just ask you to respect me and if it bothers you, don't respond. I don't want any controversy. Anyway, Happy New Year to everyone.
    1 point
  40. Greetings to all members of Cad Tutor, Based on the upcoming holidays and New Year, I'v made something interesting which I want it to share with you. Everything was made using a Lisp. I hope it will interesting to all of you and maybe give some inspiration to the next year to made something different and share it with rest of us . Notice (it is on cyrillic, in Serbian language): - ЗИМСКА СЛУЖБА = Winter service on roads; - СРЕЋНА НОВА ГОДИНА = HAPPY NEW YEAR; - XO-XO-XOO = HO-HO-HOO (). Happy New Year 2026 to all members, and wish you all the best and new codes . NovaGodina2026_CadTutor.mp4 Best regards, Saxlle.
    1 point
  41. You need to search for convert Raster to Vector programs. You can use Raster Design on the image files, but still requires some work, it doesn't work on the PDFs though. If they refuse to properly create Vector PDFs or give you a .dwg, your only option is to do them in a separate Raster/Vector program, Raster Design or trace them in AutoCAD.
    1 point
  42. I'm working and I don't have time. Not everyone is as good at programming as you. Why did you respond so rudely? I think that without creating unnecessary controversy you could have not responded if the matter bothered you. Did you have a bad Christmas? However thanks
    0 points
×
×
  • Create New...