Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. mhupp

    Read/Write Binary Files

    Rather then reading the file and then writing it back with new data added just open the file in append mode. aka add the data you want at the end. ;; Example usage: ;; (MH:AppendText "C:/path/to/your/file.txt" "This is a new line of text") (defun MH:AppendText (filename text / file) (vl-load-com) (setq file (open filename "A")) 'open file in append (if file (progn (write-line text file) (close file) (princ (strcat "\nText appended to " filename)) ) (princ (strcat "\nError: Could not open " filename)) ) (princ) ) also ZWCAD might now be able to use some of the Visualisp commands like vlax- and vl-
  3. leonucadomi

    increase or decrease value of attdef...help

    You can add something like this to make the numbering 3 digits? like this (setq i 1 ) (foreach sub lst (setq lent (entget (last sub)) txt (strcat (if (< i 10) "00" (if (< i 100) "0" "")) (itoa i)) i (1+ i) ) (entmod (subst (cons 1 txt)(assoc 1 lent) lent)) )
  4. Today
  5. leonucadomi

    increase or decrease value of attdef...help

    This tool is great but I need the numbering to be in this format 001, 050....I mean that a zero accompanies the number la numeracion que aqui manejamos usa 3 digitos
  6. Hello friends i have in attached drawing 2 3dfaces i want to apply command loft on first one and second one but when selecting first 3d face it rejected and said invalid object i was filtered out but when moving or copying this object to some other places it worked so i want an explanation of what is happening loft on 3dface.dwg
  7. rsdonna

    TCOUNT for multileaders

    Tried this one and think I'm doing it correctly but am getting a weird outcome. I enter 03 to be the text to find and 01 the text to replace it with and it numbered them sequentially but placed a space between the 0 and 1. Also I tried it again but put 08 as the replace text and it gave me the same this as if I had put 01 for the replace text.
  8. Fidelojo

    Read/Write Binary Files

    Hi, so I'm using ZWCAD and it has a file called 'AppAutoLoad.app' which stores all script files paths from Startup Suite. If I paste new path in it it works fine, accepts it and loads it upon next running of CAD software but it seams to be a binary file because when I write to it using write-line command some weird characters are written. I tried writing content to it using LISP scripts provided here by Lee Mac and it work fine when using both functions together, the content is read as a variant and that variant has been written back like this: (LM:WriteBinaryStream (findfile "../AppAutoLoad.app") (LM:ReadBinaryStream (findfile "../AppAutoLoad.app") nil)) So that worked fine in ZWCAD, but when I tried constructing variant object on my own it won't work, I tried looking on multiple forums, reading docs I could find about it, but I can't make it work, this is the function I made for appending new content to the file: (defun MM:AppendToBinaryFile ( path text / fileData ) (setq text (mapcar 'ascii (MM:strToLst text)) ; Converting text to list of corresponding ASCII values fileData (vlax-variant-value (LM:ReadBinaryStream path nil))) ; Reading variant value of the existing file data (if fileData ; Check if there is any existing data (setq fileData (reverse (vlax-safearray->list fileData))) ; Convering data to list of ASCII values and reversing it for appending new values ) (foreach letter text (setq fileData (cons letter fileData)) ; Adding every new character to the existing data ) (setq fileData (reverse fileData) ; Reversing values to restore proper order vlax-vbByte 17 ; Setting value for non-existing variant type byte-array (vlax-make-safearray vlax-vbByte (cons 0 (1- (length fileData))))) ; Creating empty safearray of appropriate size (vlax-safearray-fill byte-array fileData) ; Filling safearray with full data (old + new) (setq fileData (vlax-make-variant byte-array (+ vlax-vbArray vlax-vbByte))) ; Creating variant object (LM:WriteBinaryStream path fileData) ; Writting data back to file (princ) ) Also MM:strToLst is just a function that splits string into list of characters, I'll post it if someone needs it for testing: (defun MM:strToLst ( str / ) (if (> (strlen str) 0) (cons (substr str 1 1) (MM:strToLst (substr str 2))) nil ) ) Can anyone help on this topic or point on some error in my code? I did some testing and final safearray seems to keeps containing zeroes only even after filling it but I don't know why is that, I tried to fix it somehow but without success. I am also sending the file I am working with. After reading the content, vlax-variant-type command gives me code 8209. AppAutoLoad.app
  9. rsdonna

    TCOUNT for multileaders

    I will try that one out as well. Haven't been able to get back on here too often to try everything out because of my workload as well. I would be very interested to see the LISP with the dialog box as well. Thanks for all your help.
  10. rsdonna

    TCOUNT for multileaders

    This worked for me as well.
  11. rsdonna

    TCOUNT for multileaders

    Yes this works great!! Thanks so much. You Rock!
  12. Looks like a lot can be done with -bedit, -insert, -bsave, -bclose, attsync . I just need to put it together, bur I think I have a solution. 1. Prepare external drawing with attributes for adding 2. Open the drawing that needs to be modified (easily scripted for batch work) Script: (defun c:add_to_block_from_file ( / ) ;Add attribues or anything else from external file to a block definition (setq block_name "BLOCK_NAME") (setq att_file_path "C:\\PATH_TO_THE_FILE_FOR_ADDING.dwg") ;Use \\ in the path! (command "-bedit" block_name) (command "insert" att_file_path "E" "Y" "0,0" "1" "1" "0") (command "bsave") (command "bclose" "") (command "attsync" "Name" block_name) ) at this moment the blocks contain the new attributes so the drawing can be modified or saved.
  13. devitg

    acadauto.chm not found

    @ScottMC Thanks. Solved
  14. Thanks! I'm OK to do it drawing by drawing. I can script handling the batch. I think in python , so definitely yes. .NET - never used it. I just found out the expresstools command blockreplace, but I'm struggling to convince it to use external file as the new block. I might dig into Lee Mac library... I prepared the new block as external file, but I'm not asked to redefine the block even when inserting with full file path. Possibly some system variable controls that (*). Edit: * https://help.autodesk.com/view/ACD/2022/ENU/?guid=GUID-15A13868-7582-4CCD-A8FC-9AF2D05E689C BLOCKREDEFINEMODE
  15. Can you then have a different Lisp read the F2b value?
  16. Might be a silly question but is there a way I can add a textbox in the CUI so the user can type in text height and then this input will be read by the other lisps?
  17. Threads merged.
  18. Probably the same either way. LISP/Script would be quite capable, lot's of code around for adding attributes, pretty sure Lee Mac has something. VBA, IMO, might have a slight advantage running on multiple drawings. .NET or Python an option?
  19. I need to modify a few block definitions per drawing by adding 2 new attributes. Fixed location, they wont be visible, so I do not care if they are overlapping with other content or not. I use them as a "meta data" storage. Now, what's the best way to do it? I'm considering reinserting the block (prepared separately, with required modifications) or editing the block definition in place. The number of drawings and blocks is too large for manual modifications. I'm OK with LISP as well, but I will be populating the data from excel, so VBA seems to be the natural choice. Any advice if there is abetter way of doing it? Any opinions, comments, are more than welcome. I'm at the "brain storm" stage P.S. I currently open the block editor, paste the 2 attributes, close block editor, attsync, done. Maybe recreating that process in a scripted way with LISP would be easier?
  20. If it does require manual input I suspect the default tableay be the quicker method as fairly easy to type and tab down
  21. Looks interesting but Does this still require manually inputting 309 lines of data in 3 tables , each with multiple columns !
  22. ScottMC

    acadauto.chm not found

    Mine is in my support folder..
  23. Yesterday
  24. This post is like option 2 of this post. Is there an option 3 ? Will answer last question in other post. Suggest keep all in one post. Give this a try does both requests. (defun c:addval ( / lst lst2 att cnt lst3) (setq inc (getreal "\nEnter increment + or - ")) (setq ss (ssget '((0 . "TEXT,ATTDEF")))) (setq lst '() tnum 0 tatt 0) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (1- x))))) (setq objname (vlax-get obj 'objectname)) (if (= objname "AcDbText") (progn (vlax-put obj 'textstring (rtos (+ (atof (vlax-get obj 'textstring)) inc) 2 0)) (setq tnum (1+ tnum)) ) (progn (vlax-put obj 'tagstring (rtos (+ (atof (vlax-get obj 'tagstring)) inc) 2 0)) (setq tatt (1+ tatt)) ) ) ) (alert (strcat (rtos tnum 2 0) " text changed \n" (rtos tatt 2 0) " tags Changed")) (princ) ) If you introduce more objects may need a cond rather than using IF.
  25. I don;t think you need Excel. You can match a dcl to a dynamic block so you can enter values and then in turn update the block. It is something I have insert block and the dcl is displayed, its global code so works with any dynamic block. Need a dwg with your block and can test.
  26. Masterful
  27. I am updating a dynamic block using dummy parameters to achieve multiple visibility states, I have got it working at 2m and 3m by manually inputting data but I need to go to 40m and there are 9 visibility states for for each length. I can generate the data in Excel and ideally I want to cut paste this into the property lookup table but this is not possible. I can cut paste into a block property table but not a lookup table and adding 300+ lines manually in 3 separate tables is not practical. The attached image shows one table completed for 2 and 3m lengths. Can this data be scripted ?
  28. Load VT , start with VT (or C:VT) Click on one of the attdef's , you get the main dialog Click on setup (bottom right) and change difference to 5 , click on ok to return to main dialog Finaly click on Renum and select all attdefs , enter, done... VT uses grread in a constant loop so exit with escape, cancel or spacebar that will get you in quick menu and you can escape / Quit / cancel from there. Not all buttons will work because some are company specific like revision but for now it should get you what you need. VT.LSP
  1. Load more activity
×
×
  • Create New...