Jump to content

All Activity

This stream auto-updates

  1. Yesterday
  2. Worked for me, just have to run the lisp command and resave the dwt.
  3. ibach

    Helix Along a Path

    That would be maximal displayed accuracy... I believe that internal calculation accuracy in Auto CAD is at least 1e-20 if not greater. That is the reason i'd love to have the angle input as selection of two defining lines, not as an output of measure command in the first place.
  4. marko_ribar

    Helix Along a Path

    For maximal accuracy that CAD can provide, check (ftoa) sub function... (defun ftoa ( n / m a s b ) (if (numberp n) (progn (setq m (fix ((if (< n 0) - +) n 1e-8))) (setq a (abs (- n m))) (setq m (itoa m)) (setq s "") (while (and (not (equal a 0.0 1e-6)) (setq b (fix (* a 10.0)))) (setq s (strcat s (itoa b))) (setq a (- (* a 10.0) b)) ) (if (= (type n) 'int) m (if (= s "") m (if (and (= m "0") (< n 0)) (strcat "-" m "." s) (strcat m "." s) ) ) ) ) ) )
  5. ibach

    Helix Along a Path

    Helix tool in AutoCAD seems to be the best way to draw a ramp in 3D... The only thing it is missing is the possibility to enter number of turns by selecting the angle of the ramp that is circular... To do that i need to measure the given angle and manually calculate number of turns (<1) and input the number back to helix properties... see the picture, please... I would love to have a lisp that would allow that input selecting the two lines defining alpha... e.g. if α=60, the number of turns is 60/360=0.16666667 which i would not like to be only 8 decimals but the max of accuracy AutoCAD can achieve... Can anyone help with that?
  6. In fact there is a way how to store and run LISP apps (incl. VLX) inside DWG and DWT files but there may be security issues - see AutoExec: https://www.cadforum.cz/en/how-to-store-macros-inside-dwg-drawings-tip10647 https://www.cadstudio.cz/en/apps/autoexec/
  7. I'll assume you can copy the code to a text file and save it as something with a .lsp extension. Add the file to the startup suit from appload.... So in the code linked above there will be a ) right at the end, add a new line just before that and paste in (command "regen") in that new line. Otherwise run the find and replace LISP and then just do the CAD command "Regen" which will do the same thing but 1 extra step by the user
  8. Dmytro

    LLM-based Autocad automation

    The prototype allows usage of different models. I've used it with chatGPT 4.0o deployed via Azure. (You can also use your model from open ai directly). With some minor code adjustments it would be possible to try other models as well, i.e. mistral, ollama, etc. The strength of this prototype is the implemented workflow: we ask LLM to generate a script, we try to compile it on fly (don't know if this can be done with lisp, dotnet Roslyn API allows to do that for csharp), if a script cannot be compiled we make another request(s) to LLM to try fix the script based on errors reported by compiler. Fixing process is done in a loop. This way I guarantee the generated script can actually be compiled. The script itself might not solve the problem perfectly, cause it is just a generated by LLM, that can hallucinate. Step2 is supposed to allow fine-tuning of the script. Step-2 is very simple now: allows manual editing and automatic fixing by providing more context to an LLM. Please check out the state machine diagram on project GitHub page to better understand what I've just tried to explain.
  9. will the ldata transfer to the real drawing though once dwt is saved?
  10. Mitch Owen

    Curve Flat 3D Object

    Hi Irm, my end goal is to have a curved 3D object with the pattern in it. The cutouts are 60mm diameter with a 2mm gap in between. I won’t be back at my computer until early next week and can attach the dwg file then.
  11. thank you for the response I have no experience with autocad lisp im not sure where I would add the regen in the code
  12. Wish I could say, why didn’t I think of that, but I think we both know I would have never thought of that. I’m even afraid to ask ChatGPT to try it. Might break something. Although I can always try it on another file.
  13. lrm

    Curve Flat 3D Object

    @Mitch Owen what is your end goal? Do you want 3D curves in space or just a rendering of what it would look like? Can you post the AutoCAD file or at least the dimensions of one the cut-out patterens?
  14. Last week
  15. Included with CIV3D is a carparking dynamic block just stretch and makes bays etc . Parking Tools - Imperial.dwgParking Tools - Metric.dwg Something I use may be useful. carpark made simple.lsp
  16. BIGAL

    LSP for creating multiple colored hatches

    This has been asked before you can get max min elevation and set a range of colors. A better way than just using a color a your limited to 254 colors. CIv3D has this function built in display contours via color.
  17. @Steven P nice idea thinking post value to A1 and call the VBA macro in Excel, then read the cell B1. Can you post a working excel with macros set up please. Ok found some help Press Alt+F11 to open the Visual Basic Editor (on the Mac, press FN+ALT+F11), and then click Insert > Module. A new module window appears on the right-hand side of the Visual Basic Editor. Copy and paste the following code to the new module. The =Translate(A1, "en", "fr") should now work. Convert to French. Ok a bit of lisp, I do know the translate has a character limit. (defun c:translate ( / myxl obj txt myrange) (or (setq myxl (vlax-get-object "Excel.Application")) (setq myxl (vlax-get-or-create-object "excel.Application")) ) (vla-put-visible myXL :vlax-true) (vlax-put-property myxl 'ScreenUpdating :vlax-true) (vlax-put-property myXL 'DisplayAlerts :vlax-true) (while (setq txtent (car (entsel "\nSelect a text Enter to exit "))) (setq obj (vlax-ename->vla-object txtent)) (setq txt (vlax-get obj 'Textstring)) (setq myRange (vlax-get-property (vlax-get-property myxl "ActiveSheet") "Range" "A1")) (vlax-put-property myRange 'Value2 txt) (setq myRange (vlax-get-property (vlax-get-property myxl "ActiveSheet") "Range" "B1")) (vlax-put obj 'Textstring (vlax-variant-value (vlax-get-property myRange 'Value2))) ) (if (not (vlax-object-released-p myRange))(progn(vlax-release-object myRange)(setq myRange nil))) (if (not (vlax-object-released-p myXL))(progn(vlax-release-object myXL)(setq myXL nil))) (princ) ) (c:translate) How to use big thanks @Steven P open excel and make the function, yes save the blank Excel for future use. Put the =Translate(A1, "en", "fr") in cell B1. Just select text BIG BUT only use single line text at moment maybe a mtext version later. I copied the text for testing. You should see in Excel the A1 cell changing same with B1 to new language. Theoretically could select multi text in one go and watch it change. Replace while with a selection set. One question to Steven how did you find the "fr" for French ? Sort of found a way to work out the id. "gn" german ? "it" Italian ?
  18. Welcome to the forums. ssget is what your looking for. you can use that to filter by entity type, layer, color basically anything in the DXF code. so all you really have to do is drag a window around everything to make one selection. This will dump the dxf codes of a selected entity to the command line ;;----------------------------------------------------------------------------;; ;; Dump all DXF Group Data (defun C:DumpIt (/ ent) (while (setq ent (car (entsel "\nSelect Entity to Dump"))) (mapcar 'print (entget ent '( "*"))) ) (princ) ) Lee Mac has a great website going over all the ssget options this will only select lines on "parking line" Layer - (setq ss (ssget '((0 . "LINE") (8 . "PARKING LINE")))) from there you can use the end points to calculate the distance of said lines to filter down to the "long ones" Took a little time to add a few QOL to your code. (defun c:foo (/ s d p LastEnt SS en) ;; Tharwat 14. Dec. 2011 ;; Modified by Mhupp (setq SS (ssadd)) ;A blank selection set is need to add things to later (while (setq s (car (entsel "\nSelect entity: "))) ;keeps repeating the command if you keep selecting things (if (not (member (cdr (assoc 0 (entget s))) '("*LINE" "CIRCLE" "ARC" "ELLIPSE"))) ;checks to see if the selection is a type of entity in the list (progn ;remove any if you want the command to prompt you to select again (prompt "\nCan't Offset Selected Object, Try again") (c:foo) ; Call the command again for retry (recursion) if you rename this command rename it here to. ) (progn (if (setq d (getdist "\nDistance of offset <1>: ")) ;getdist allows you to key in things like 12'6" or use your mouse. (progn) ;if d is set do nothing (setq dist 1) ;Else if the user presses Enter, set d to 1 ) (setq p (getpoint "\nSpecify Offset Side: ")) ;; Store the last entity created before the offset, Offset can create multiple entitys (setq LastEnt (entlast)) (command "_.offset" d s p "") ;; Add all newly created entities to the selection set (while (setq en (entnext LastEnt)) (ssadd en SS) ) ;; Process the newly created Selection set (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) ;this will create a list of entity name in selection set SS (setq vlaEnt (vlax-ename->vla-object ent)) ;gets the visual list name of an entity ;; Set color to "ByLayer" (vla-put-color vlaEnt acByLayer) ;; Set to the layer "PR-HATCH-PARKING BAY-RESIDENT PERMIT ONLY" (vla-put-layer vlaEnt "PR-HATCH-PARKING BAY-RESIDENT PERMIT ONLY") ;; Set width to 2 (vla-put-ConstantWidth vlaEnt 2.0) ;always good pratice to use real numbers and not integer (command "_.draworder" ent "back") ) ) ) ) (princ) ) Modified from here
  19. BIGAL

    Curve Flat 3D Object

    As a 3d object to view ? You can draw an pline with inside outside arcs and extrude, so a solid curved sheet. It is possible to "subtract" a 3d solid shape from this sheet, the issue is that the plug to be used has be arrayed in a circular pattern. A tricky but doable task, the result will hopefully look like what you want, but don't dim the cutouts. This is opposite to what you want, but similar idea, some one else more experienced with solids will probably help. The lettering is extruded through a curved surface.
  20. When you open a dwt it loses its name as a dwt and becomes a dwg, as suggested by @lastknownuser you can store a variable in the dwt using LDATA. A startup lisp can look for that value. ; inside dwt do this once (vlax-ldata-put "DWTS" "DWTNAME" "actualdwtname") ; autoload lisp (if (= (vlax-ldata-get "DWTS" "DWTNAME") nil) (princ "\nNot a dwt") (load "all the lisps here") )
  21. BIGAL

    LLM-based Autocad automation

    How does it compare to ChatGP and MS Pilot ? Providing the same code ? COPILOT "Make 12 random objects line circle pline in model space within bounds 0,0 1000,1000. Using Autocad lisp" The result was so close missing a closing ). (defun c:RandomObjects () (defun random-point (min max) (list (+ min (random (- max min))) (+ min (random (- max min))))) (defun random-radius (min max) (+ min (random (- max min)))) (defun create-random-line () (entmake (list (cons 0 "LINE") (cons 10 (random-point 0 1000)) (cons 11 (random-point 0 1000))))) (defun create-random-circle () (entmake (list (cons 0 "CIRCLE") (cons 10 (random-point 0 1000)) (cons 40 (random-radius 10 50))))) (defun create-random-polyline () (entmake (append (list (cons 0 "LWPOLYLINE") (cons 90 4)) (mapcar '(lambda (pt) (cons 10 pt)) (list (random-point 0 1000) (random-point 0 1000) (random-point 0 1000) (random-point 0 1000)))))) (repeat 4 (create-random-line)) (repeat 4 (create-random-circle)) (repeat 4 (create-random-polyline)) (princ "\n12 random objects created in model space.") (princ) ) (c:RandomObjects)
  22. If you use this makes a list of the attributes, you can then use a (foreach att atts to look at each attribute. (setq atts (vlax-invoke obj 'Getattributes)) Using VLAX rather than VLA-get I just find easier (vlax-get obj 'layer), its like a noun verb, verb noun thing.
  23. BIGAL

    Hardware Choice

    I would go more than an I3 at least an I5 a I7 is preferable.
  24. Theking20212030

    LSP for creating multiple colored hatches

    I guess the first lsp (foo) works only on associative hatches
  25. Theking20212030

    LSP for creating multiple colored hatches

    This one elevates the hatch to the boundary elevation: (defun c:foo (/ lw s v) (if (setq s (ssget ":L" '((0 . "HATCH")))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (and (setq lw (cdr (assoc 330 (reverse (entget e))))) (setq v (cdr (assoc 38 (entget lw)))) (vla-put-elevation (vlax-ename->vla-object e) v) ) ) ) (princ) ) and this one creates multiple hatches each by boundary (closed polylines) colors, except the hatches it creates can't be moved by the above lsp, AND the colors are approximated index colors (not RGB): (vl-load-com) ;; See thread here: https://www.cadtutor.net/forum/topic/77467-hatch-to-each-of-the-closed-polylines-match-the-colour-layer/ ;; Program to hatch closed polylines to match the layer and colour of each selection polyline. ;; Answer by fuccaro and added undo handling and changed the selection method by myself (3dwannab) ;; First written on 2023.05.11 (defun c:HBC nil (c:HH_Boundary_Colour)) (defun c:HH_Boundary_Colour (/ *error* acDoc hatch i p pl ss1 var_cmdecho var_osmode) (defun *error* (errmsg) (and acDoc (vla-EndUndoMark acDoc)) (and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " errmsg " >>\n")) ) (setvar 'cmdecho var_cmdecho) (setvar 'osmode var_osmode) ) (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)) (setq var_cmdecho (getvar "cmdecho")) (setq var_osmode (getvar "osmode")) (setvar 'cmdecho 0) (setvar 'osmode 0) (setq ss1 (ssget ":L" (list '(0 . "LWPOLYLINE") '(70 . 1)))) (repeat (setq i (sslength ss1)) (setq p (ssname ss1 (setq i (1- i)))) (setq pl (entget p) lay (assoc 8 pl) color (assoc 62 pl) ) (command "_hatch" "s" p "") (setq hatch (entget (entlast)) hatch (subst lay (assoc 8 hatch) hatch) ) (cond (color (setq hatch (append hatch (list color)))) ) (entmod hatch) ) (*error* nil) (princ) ) (princ (strcat " \n: ------------------------------\n'Hatch_Boundary_Colour.lsp' Loaded | Invoke by typing 'HH_Boundary_Colour' or 'HBC'.\n: ------------------------------\n")) (princ)
  26. Well done, onto a slippery slope though "I wonder if I can make a LISP that can do....." We might need a sample of a drawing to check and confirm how you draw things. I'll take a guess that the parking bay lines are unique in some way, perhaps on their own layer, so to set you off you might use ssget with a filter for the layer (setq ParkingLines (ssget (list (cons 8 Parking-Lines-Layer))) ) and if you use (ssget "_X" ... ) it will select everything else you select in the first example ( see https://lee-mac.com/ssget.html - Lee Mac has a lot of excellent resources, same as this website, AfraLisp and The Swamp) In your code you can then ditch the (repeat 1000) (by the way there are better ways but this can work) and use a while loop perhaps: (setq acount 0) (while (< acount (sslength ParkingLines)) ... do stuff (setq MyLine (ssname ParkingLines acount)) (command "_.chprop" MyLine "" "LT" "Bylayer" "LA" "PR-HATCH-PARKING BAY-RESIDENT PERMIT ONLY" "") ;set item to layer .... (setq acount (+ acount 1)) ) ; end while If it was me I'd perhaps create a selection set of the parking bay lines and loop through that set (as above), zoom to and highlighting each polyline in turn (use redraw -entity name- 3 to highlight, 4 to remove highlight), user can select side, draw the hatch and move on. If the parking bay line is always [ shaped and a polyline you could automate the offset side by using the 1st point in the polyline definition as the offset selection. If I remember after the weekend this might be an interesting on to look at
  27. Yes that is possible, with LISP you can place a block using the entmake or entmakex method (for pure LISP) or the vla-insertblock (Visual LISP). These blocks can be defined with fields. You can use LISP to define the block definition including fields. Might need a little more information as to what exactly you want and perhaps a sample drawing s a demonstration of the fields to use
  1. Load more activity
×
×
  • Create New...