Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. Hi all; I found this lisp below on the internet it works perfectly, but i have multiple lines i need to enter the radius for each line, so i was wondering if anyone can help me to let the lisp take the same fillet as regular fillet without asking each time and the lisp repeat it self untill pressing "ESC", Thanks in advance ; fillet with Radius, First keep, second trim (defun c:FCLL (/ *error* adoc oVAR nVAR getval e1 e2 entq p2 l l1 e er ss 1pt 2pt midpt ename param oblouk LayerName z1) ;******** (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end")) (princ (strcat "\nError: " errmsg))) (mapcar 'setvar nVAR oVAR) (vla-endundomark adoc) (princ)) ;;; GETVAL - returns the group value of an entity. ;;; like the wellknown (dxf) function but accepts all kinds of ;;; entity representations (ename, entget list, entsel list) (defun GETVAL (grp ele) ;"dxf value" of any ent... (cond ((= (type ele) 'ENAME) ;ENAME (cdr (assoc grp (entget ele))) ) ((not ele) nil) ;empty value ((not (listp ele)) nil) ;invalid ele ((= (type (car ele)) 'ENAME) ;entsel-list (cdr (assoc grp (entget (car ele)))) ) (T (cdr (assoc grp ele)))) ); end getval (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object)))) (setq oVAR (mapcar 'getvar (setq nVAR '(CMDECHO TRIMMODE PEDITACCEPT OSMODE)))) (mapcar 'setvar nVAR '(1 0 1 0 )) (setvar "filletrad" (cond ((getreal (strcat "\nSpecify fillet radius <" (rtos (getvar "filletrad") 2 2) ">: "))) (T (getvar "filletrad")))) (while (and (null (setq e1 (entsel "\nSelect first object (TO BE MODIFIED): "))) (wcmatch (getval 0 e1) "LINE,ARC,LWPOLYLINE"))) ;Identify the layer of the first selected entity (setq LayerName (cdr (assoc 8 (entget (car e1))))) (redraw (car e1) 3) (while (and (null (setq e2 (entsel "\nSelect second object (REMAINS THE SAME): "))) (wcmatch (getval 0 e2) "LINE,ARC,LWPOLYLINE"))) (redraw (car e2) 3) (setq p1 (cadr e1)) (setq e1 (car e1)) (if (= (getval 0 e1) "LWPOLYLINE") ;if 1nd polyline (progn (setq l (entlast)) (command "_.EXPLODE" e1) ;make it line or arc (would be trimed) (setq ss (ssadd)) (ssadd (setq e (entnext l)) ss) (while (setq e (entnext e)) (ssadd e ss)))) (if (= (getval 0 e2) "LWPOLYLINE") ;if 2st polyline (progn (setq ename (car e2) midpt (vlax-curve-getClosestPointTo ename (trans (cadr e2) 1 0)) param (vlax-curve-getParamAtPoint ename midpt) 1pt (vlax-curve-getPointAtParam ename (fix param)) 2pt (vlax-curve-getPointAtParam ename (1+ (fix param)))) (if (> (abs (- (- (vlax-curve-getDistAtPoint ename 2pt) (vlax-curve-getDistAtPoint ename 1pt)) (distance 2pt 1pt))) 0.002) (setq oblouk T)) (if oblouk (command "_.ARC" 1pt midpt 2pt) ;make it line or arc (would be keeped) (command "_.LINE" 1pt 2pt "")) (setq l2 (cons (entlast) (list (cadr e2)))))) ;if 1st line or arc (if (wcmatch (getval 0 e2) "LINE,ARC,CIRCLE") (progn (entmake (entget (car e2))) ;duplicat it (setq l2 (cons (entlast) (list (cadr e2)))))) (setvar "trimmode" 1) (command "_.FILLET" (nentselp p1) l2) ;new arc (setq er (entlast)) (command "_.CHANGE" er "" "_P" "_LAyer" LayerName "") ; change layer (entdel (car l2)) ;trim substitude of 1st erased (if ss (command "_.PEDIT" er "_J" ss "" "" ;if 2nd was pl, recreate pl "_.ERASE" ss "")) ;the rest of it (2nd side) erase (command "_.REGEN") (*error* "end") (princ) )
  3. Steven P

    Entmake Fields

    Part 2 of my weekend homework, adding more for info. This one searches for blocks, gets the object ID for a named attribute and returns the field expression for that attribute. MyString is a default text if the required attribute isn't found in any blocks (loop stops when it finds the named attribute in a block). Example I was looking at is as my Insert blocks DCL, above, adding in a drawing border made of a few blocks one of them is a field from the drawing number - adding in the title block the object name is dynamic, this gets the code needed for that title block (defun PMField ( MyField MyString / MyBlocks Ent acount Att x tmplist) (setq MyBlocks (ssget "_X" '((0 . "INSERT")))) (setq acount 0) (while (and (equal tmplist nil) (< acount (sslength MyBlocks))) (setq Ent (ssname MyBlocks acount)) (foreach Att (vlax-invoke (vlax-ename->vla-object Ent) 'GetAttributes ) ;_ end of vlax-invoke (if (= (strcase (vla-get-TagString Att)) MyField) (setq tmpList (cons Att (vla-get-TextString Att))) ) ; end if ) ; end foreach (setq acount (+ acount 1)) ) ; end while (if (equal tmplist nil) (progn (princ (strcat "No block with attribute '" MyField "' found")) ;; (setq MyString "OFFICIAL") ) (progn (setq x (car tmplist)) (setq MyString (strcat "%<\\AcObjProp Object(%<\\_ObjId "(itoa (vla-get-objectid x))">%).TextString>%")) ) ; end progn ) ; end if MyString )
  4. Steven P

    Entmake Fields

    Coming back to this one again... I came on this solution, weekend testing and it works so far. Just needs the vla-put-textstring to update the text to a field. Not checked yet if it will do a nice mix of text and field - should do. Also noted that can entmake text with a field embedded into a block - doesn't need that extra line, when block is inserted it does its stuff (example, attributes for drawing number and drawing number repeated at the top left corner as a field.. see next comment) (setq MyString -String including field codes- ) (setq MTextObj (vlax-ename->vla-object (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(67 . 0) '(8 . "0") '(100 . "AcDbMText") '(10 0.0 0.0 0.0) '(40 . 2.5) '(41 . 0.0) '(46 . 0.0) '(71 . 1) '(72 . 5) (cons 1 MyString) '(7 . "Standard") '(11 1.0 0.0 0.0) '(42 . 15.4246) '(43 . 2.58697) '(50 . 0.0) '(73 . 1) '(44 . 1.0) )) ; end entmakex ; end list )) ; end vlax-ename ; end setq (vla-put-textstring MTextObj MyString) ;; update field.
  5. Today
  6. Slowly getting some where, this looks through the block including nested blocks and finds the visibility state for nested blocks. I have no idea how many are nested in the block. or why I am getting multiple answers in the dcl but they change. So keep picking different answers than default button 1, I got stuff changing. Maybe make the heading the block name. (defun c:BlockEnts_mod ( / :block e att1 att_entlst1) (setq lst '()) (defun :block (e l) (setq l (1+ l)) (while (setq e (entnext e)) (princ (strcat "\n" (itoa l) ":")) (if (not (member (cdr (assoc 0 (entget e))) (list "ATTDEF" "SEQEND"))) (princ (cdr (assoc 0 (entget e)))) ) (if (= "INSERT" (cdr (assoc 0 (entget e)))) (setq lst (cons e lst)) );if );while );defun (if (setq e (car (entsel "Select block: "))) (progn (if (assoc 66 (entget e)) (progn (setq att1 (entnext e) att_entlst1 (entget att1) ) (while (= "ATTRIB" (cdr (assoc 0 att_entlst1))) (princ (strcat "\n1:" (cdr (assoc 0 att_entlst1)) )) (setq att1 (entnext att1) ) (if att1 (setq att_entlst1 (entget att1) )) );while );progn );if (princ "\n------") (:block (tblobjname "BLOCK" (cdr (assoc 2 (entget e)))) 0) );progn );if (princ) );defun (c:BlockEnts_mod) (defun insdyne (e / pt obj lst ans) (if (not LM:setdynpropvalue )(load "Lee-mac Dynamic block get-put")) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (setq obj (vlax-ename->vla-object e)) (setq visval (LM:getvisibilityparametername obj)) (if (= visval nil) (princ) (progn (setq lst (LM:getdynpropallowedvalues obj visval)) (setq lst (cons "Please choose" lst)) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (not AHbut)(setq AHbut 1)) (setq ans (ah:butts 1 "v" lst)) ) ) (LM:SetVisibilityState obj ans) (princ) ) (defun dynnn ( / ) (foreach ent lst (insdyne ent) ) (dynnn) The more I look at this the more I believe to do it as parts as the blocks make up an object you can set each part visibility way easier than making like 900 visibility states. A big advantage is can make a table of the quantities involved per structure or even per dwg. Counting common objects etc.
  7. For more tools related to MLeader, you can consider using this one: https://lispautocad.gumroad.com/l/eezilo
  8. BIGAL

    Text content sync

    There is vlr-object-reactor, which can call a defun like your lisp. i dont know how though you would pass it the correct block object to change. If you make the text a block then you could have a invisible attribute which is the handle ID of the matching block. https://www.google.com/search?q=reactor+object+cahnged+autocad+lisp&sca_esv=3b7e4dc23e2c7901&source=hp&ei=KKWOaOmOLsaU4-EPgIS0-Qk&iflsig=AOw8s4IAAAAAaI6zOGqTE_bufe0aJLcdS0xRbMY74k-X&ved=0ahUKEwjpwoS9qe2OAxVGyjgGHQACLZ8Q4dUDCA8&uact=5&oq=reactor+object+cahnged+autocad+lisp&gs_lp=Egdnd3Mtd2l6IiNyZWFjdG9yIG9iamVjdCBjYWhuZ2VkIGF1dG9jYWQgbGlzcDIHECEYoAEYCjIFECEYnwVI4lFQgwpY-ExwAXgAkAEAmAGWAqAB1TWqAQcwLjE4LjE3uAEDyAEA-AEBmAIkoALFNqgCCsICChAAGAMY6gIYjwHCAgsQABiABBixAxiDAcICCxAuGIAEGLEDGIMBwgIREC4YgAQYsQMY0QMYgwEYxwHCAg4QLhiABBixAxiDARiKBcICDhAAGIAEGLEDGIMBGIoFwgIIEAAYgAQYsQPCAg4QLhiABBixAxjRAxjHAcICCxAuGIAEGNEDGMcBwgIOEAAYgAQYsQMYgwEYyQPCAg4QABiABBixAxiSAxiDAcICCxAAGIAEGJIDGIoFwgIUEC4YgAQYsQMYgwEYxwEYjgUYrwHCAggQLhiABBixA8ICDhAuGIAEGMcBGI4FGK8BwgIFEAAYgATCAgUQLhiABMICBhAAGBYYHsICCBAAGBYYChgewgILEAAYgAQYhgMYigXCAgUQABjvBcICCBAAGIAEGKIEwgIIEAAYogQYiQXCAgUQIRigAcICBhAhGBUYCpgDBvEFDVTDEYK0XNeSBwcxLjE4LjE3oAfdwwGyBwcwLjE4LjE3uAe-NsIHBzExLjE3LjjIB04&sclient=gws-wiz You could do a lisp that saves the two objects handles and use the reactor on close, save & quit to update via lisp the objects. I have used save etc to do something. I use ldata to save values in a dwg so you would have one data value which is how many, then you would have multiple values saved. The other method is to use Xdata on say the text saving the block ID. Again the handle. Doing the text on specific layers may make it fast to check v's getting all text in the dwg.
  9. Yesterday
  10. harimaddddy

    custom .pc3 not supported

    Hi @Steven P and all to friends, With help of AutoCAD forum I got solution upto 95%. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-pc3-not-supported/m-p/13750967#M165599 Remaining 5% issue were posted. Could you guys help with this?. Thanks in advance
  11. Convert leaders to multileaders by picking in pairs, add more content, and assign custom layers — all in one smart tool. Save time and stay organized: https://lispautocad.gumroad.com/l/eezilo
  12. DATVO

    Leader with text

    If you're tired of dealing with countless hard-to-manage leaders, or want to add more content, try this tool — it will help you save a lot of time: https://lispautocad.gumroad.com/l/eezilo
  13. Fidelojo

    Read/Write Binary Files

    Well I feel quite stupid now Since reading and writing to a file using those funcions for working with binary files by Lee worked, I thought that it must be a binary file, but I guess that whenever I'm reading from a file a writing the result back to it, the behaviour will be the same since those are working in a same opposite way, as long as reading and writing are both done as binary, ansi or something else. Anyway thanks for help, I'm not in the office now for few days, but I'll test it when I get back. But I think that's it, big thanks.
  14. the app shown in the video looks superb, we really need something like this.....however despite significant cad experience have very little programming knowledge outside of VB. Chat GPT suggested the only way to add data to the lookup table was using a C# programme as lisp was unable to do it? using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; using System; using System.Collections.Generic; using System.IO; using System.Linq; [assembly: CommandClass(typeof(AutoCAD_CSVImport.MyCommands))] namespace AutoCAD_CSVImport { public class MyCommands { [CommandMethod("ImportLookupTable")] public void ImportLookupTable() { // File path to your CSV string filePath = @"C:\path_to_your_file.csv"; // Check if the file exists if (!File.Exists(filePath)) { Application.ShowAlertDialog("File not found: " + filePath); return; } // Read CSV file List<string[]> data = ReadCSV(filePath); // If there is data if (data.Count > 0) { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Transaction tr = db.TransactionManager.StartTransaction(); try { // Open the Block Table for writing BlockTable blockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord blockTableRecord = (BlockTableRecord)tr.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite); // Loop through the CSV data foreach (var line in data) { string code = line[0]; string field1 = line[1]; string field2 = line[2]; string field3 = line[3]; string field4 = line[4]; string field5 = line[5]; // Insert or update data into a Dynamic Block or a Lookup Table // (Assuming you already have a dynamic block setup) // This is where you would link to your Lookup Table or Dynamic Block // For now, we're just printing out the data Application.ShowAlertDialog($"Adding: {code}, {field1}, {field2}, {field3}, {field4}, {field5}"); } // Commit the transaction tr.Commit(); } catch (Exception ex) { Application.ShowAlertDialog("Error: " + ex.Message); } finally { tr.Dispose(); } } } // Helper method to read CSV private List<string[]> ReadCSV(string path) { var data = new List<string[]>(); try { using (var reader = new StreamReader(path)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); string[] values = line.Split(','); // Add the data to list (excluding empty lines) if (values.Length > 0) { data.Add(values); } } } } catch (Exception ex) { Application.ShowAlertDialog("Error reading file: " + ex.Message); } return data; } } } i have attached the original block that i am trying to update with alternative ends using multiple vis states. There is a pattern in the viz states after 12m s shown below. Adding 3 options for the ends creates 9 x the number of existing visibility states. A DCL is definitely the way to go as I imagine we could use this to produce the plans and elevations (also similar dynamic blocks) simultaneously. I have a concern that block distribution/sharing would be more complex if using an in-house dcl. jam3.dwg
  15. programme for multiple vis sates is called visibility-add-eng_1_6.lsp looks very (very) useful.. multiple visibility states and examples
  16. harimaddddy

    Text content sync

    Hi all, I'm try to build a lisp program to link content of a text and attributes/text. Somehow I manage to place the values in side the attribute with example code references. When comes to introduce a reactor to maintain the sync between the contents I can't. Thus, this text sync can be done with Field but If someone delete the source then its mess. So I came up with this idea. text has the format like SEC_NO,TAG_NO,FLAG_NO. Those would link with same tag named attribute and the copy of blocks as well. Once master text value change the respective values in attribute would change (See snap). if it turns hard, text to text would save tons of time and can use with multiple times. Thanks in advance. trail.lsp TextSync.dwg
  17. the dcl seems to show the same thing as the visibility drop down box ? is the only difference multiple radio buttons. Vs a list box ?
  18. have another look at the video, it starts with overall sizes, then gets deeper asking for edge type, the next step is how many window panes hor & ver then the size of the panes. So in your case I exploded the sample block and started to get into the other dynamic blocks, there is no problems inserting a dynamic block then popping up the visibility choices to what you want it set to. I am happy to help. so have a think about an approach first step would be the top row matching visibility lengths. Next step would be the left and right edges type may be different. then central columns. Here is some code if you explode your block so now have separate dynamic blocks, just pick one and a dcl will be made displaying the visibility options. Ok save the Multi radio buttons and Dynamic block get put lee mac to a support path as they are autoloaded. Save this code and appload it etc (defun insdyne ( / pt obj lst ans) (if (not LM:setdynpropvalue )(load "Lee-mac Dynamic block get-put")) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (setq obj (vlax-ename->vla-object (car (entsel "\nPick a dynamic block ")))) (setq visval (LM:getvisibilityparametername obj)) (setq lst (LM:getdynpropallowedvalues obj visval)) (setq lst (cons "Please choose" lst)) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (not AHbut)(setq AHbut 1)) (setq ans (ah:butts 1 "v" lst)) (LM:SetVisibilityState obj ans) (princ) ) (insdyne) So pick the truss displayed, the visibility for that block are displayed and you choose. Dynamic block get-put Lee-mac.lspMulti radio buttons.lsp
  19. You can refer to this tool — I find it handles large file volumes well and even provides a report file. https://lispautocad.gumroad.com/l/rnyiew
  20. You can refer to this tool — I find it handles large file volumes well and even provides a report file. https://lispautocad.gumroad.com/l/rnyiew
  21. The block jam1 works well for 2.3 and 14m and provides the flexibility to change length, lhs end type and rhs end type. it is a shame that acad do not provide inherent multiple visibility parametrs as the workaround is quite clunky and labour intensive .it is also unfortunate that data cannot be pasted or scripted into lookup tables. the workaround doesn’t work with block property table. I have seen a website that provides an addin to allow multiple visibility parameters and have looked at a block created with this that works well. Did you say Lee Mack also has a routine to do this ? Because there are several other permutations I need to include I Ithink you are correct regarding the use of multiple dynamics blocks, this requires a few more clicks to use but will ultimately save a lot of time having not to explode the block and adjust the contents . . the data generation in Excel is simple , putting the data into lookup tables is where I am struggling as it requires manually entering 1500 items of data into separate cells . So much easier with block properties table where it is one operation using simple cut paste . This is why I am now preparing multiple dynamic blocks and splitting out the various structural element types . Thank you for your help with this I will spend some time and try to understand the lisp provided .
  22. CivilTechSource

    closed polyline with automatic hatch

    So I saw this post and came up with the idea to create a lisp to draw polyline once closed it will insert the area of the polyline at the centre (this is for drainage catchment). Did I overcomplicate the lisp? Initially I was going for static text, but I am all about making life easier so tried to merge the ATC function from the lisp here https://jtbworld.com/autocad-areatext-lsp . Any feedback on the below lisp would be appreciated. Thank you all! (setq jtbfieldformula ">%).Area \\f \"%lu2%pr1%ps[,m²]%ct8[0.001]\">%") (defun Get-ObjectIDx64 (obj / util) (setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)) ) ) (if (= (type obj) 'ENAME) (setq obj (vlax-ename->vla-object obj)) ) (if (= (type obj) 'VLA-OBJECT) (if (> (vl-string-search "x64" (getvar "platform")) 0) (vlax-invoke-method util "GetObjectIdString" obj :vlax-False ) (rtos (vla-get-objectid obj) 2 0) ) ) ) (defun c:CTS-DrawGullyCatchment () (if (not (tblsearch "LAYER" "CTS-Gully Catchment")) (command "-LAYER" "_M" "CTS-Gully Catchment" ;;Set Layer Name "_C" "True" "0,255,0" ;;Set Color "CTS-Gully Catchment" ;;Set Layer Name "") ) (command "._pline") (while (and (not (initget 32)) (if pt (setq pt (getpoint pt)) (setq pt (getpoint)) ) ) (command pt) ) (command "_c") (if (and (setq e (entlast)) ; 'e' now holds the entity name of the polyline (setq el (entget e)) (= (cdr (assoc 0 el)) "LWPOLYLINE") (= (logand (cdr (assoc 70 el)) 1) 1) ) (progn (command "._area" "_o" e) ;;(setq GullyArea (getvar "area")) ; Get the area of the polyline ;;(setq GullyAreaTxt (strcat (rtos GullyArea 2 2) "m2")) ;;(setq GullyAreaTxtPt (getpoint "\nSpecify point for Guylly Cathcment text:")) (vl-load-com) (setq entObject (vlax-ename->vla-object (setq ent (entlast)))) (setq entObjectID (Get-ObjectIDx64 entObject)) (setq lastpt (getvar "lastpoint")) (setq InsertionPoint (vlax-3D-Point(trans (osnap lastpt "_gcen") 1 0))) (setq ad (vla-get-ActiveDocument (vlax-get-acad-object))) (setq mtextobj (vla-addMText (if (= 1 (vla-get-activespace ad)) (vla-get-modelspace ad) (if (= (vla-get-mspace ad) :vlax-true) (vla-get-modelspace ad) (vla-get-paperspace ad) ) ) InsertionPoint 0.0 (strcat "%<\\AcObjProp Object(%<\\_ObjId " entObjectID jtbfieldformula ) ) ) (vla-put-AttachmentPoint mtextobj 5) (vla-put-insertionPoint mtextobj InsertionPoint) ) ) )
  23. As I said previously I believe would be much easier to just enter length and end types. Draw correct shape or use multiple dynamic blocks rather than trying to put it all into one block. I exploded your block with different lengths and start to see patterns. There is another post at the moment that has asked about changing nested dynamic blocks changing each block individually. I am looking at that. Using a DCL for input of data may be the way to go hence the movie showing input data which includes right and left edges. One thing I noticed is that if you say 5m length it makes a 3m+2m lengths structure, so that leads me on to the next step, I can make a Excel say 2-50 using the code I provided it will make the "howmany" 6x 5x 4x 3x 2x etc you can then change so a 8 will become 2x4m (0 0 2 0 0) or a 5+3m (0 1 0 1 0) your choice then can read the Excel for matching lengths, then ask about end types. Or put the sizes into the lisp code.
  24. Last week
  25. BIGAL

    Read/Write Binary Files

    Like Lee inside Notepad++ is the correct encoding and it is detected which is why I could read.
  26. Lee Mac

    Read/Write Binary Files

    The file is not a binary file, it is just a plain text file using UTF-16 big endian encoding (most text files are ANSI). To read/write it, you cannot use open/read-line/write-line on AutoCAD, as these do not support Unicode double-byte encoding. Instead, you can use the ADO Stream object - here are some existing examples from VovKa: https://www.theswamp.org/index.php?topic=39617.0
  27. The actual TAG name, in the drawing you posted it is ADRES
  28. gilsoto13

    Deleting Hatch from Blocks

    you da man
  29. It ask you to set such distance Or you mean to set distance for each block at the straight line?
  1. Load more activity
×
×
  • Create New...