Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/15/2023 in all areas

  1. So how are your LISP abilities? If you follow the link that Tombu found it explains how to add another column then to do a count I think you should add: From Lee Mac, Add this as a separate function or a sub routine: ;;http://lee-mac.com/uniqueduplicate.html (defun LM:CountItems ( l / c x ) (if (setq x (car l)) (progn (setq c (length l) l (vl-remove x (cdr l)) ) (cons (cons x (- c (length l))) (LM:CountItems l)) ) ) ) To use that you'll need a list to add all the lines to something like this near the beginning of the LISP (setq Countlines (list)) You'll want to populate the list, with this line somewhere in the first repeat loop, after the (setq e... ) line (setq Countlines (append Countlines (list (vlax-get e 'Layer)))) and then send this to Lee Macs function to count the unique number of layers used, best if this is after the end of the first repeat of course (setq Countlines (LM:CountItems Countlines)) Then using the example and copying what is in the LISP already, populate the table column with this probably just before the line containing ;set color markers - though that is not so important so long as it is with the table creation part (vla-setCellValue Area_table crow 2 (cdr (assoc (car d) CountLines))) ;Count (vla-setcelltextheight Area_table crow 2 500.0) (vla-setCellAlignment Area_table crow 2 5)
    2 points
  2. Not wanting the brain to atrophy over the holiday season. I thought to post a hatch pattern that I have called Trilobe-E. I expect others can make a hatch pattern faster with various tools, but I like to use Autocad and trigonometry (in a spread sheet). It was based on a unit sized hexagon. As the grid is a hexagonal one instead of an orthogonal one, the brain was given good exercise. I am posting the text of the file as well as the pattern file. *Trilobe-E, trilobe pattern 307.589089469,3,3,12.1236363414,0.1320676359,0.15069,-19.521625573 322.410910531,3.0919,2.8806,9.6409374243,-0.2287478555,0.15069,-11.2071266916 337.589089469,3.2113,2.7887,9.6409374243,0.2287478555,0.15069,-11.2071266916 352.410910531,3.3506,2.7312,12.1236363414,-0.1320676359,0.15069,-19.521625573 7.589089469,3.5,2.7113,12.1236363414,0.132067636,0.15069,-19.521625573 22.410910531,3.6494,2.7312,9.6409374243,-0.2287478555,0.15069,-11.2071266916 37.589089469,3.7887,2.7887,9.6409374243,0.2287478555,0.15069,-11.2071266916 52.410910531,3.9081,2.8806,7.5486792315,0.132067636,0.15069,-19.521625573 112.410910531,4,3,12.1236363414,-0.132067636,0.15069,-19.521625573 97.589089469,3.9425,3.1393,-9.6409374243,-0.2287478555,0.15069,-11.2071266916 82.410910531,3.9226,3.2887,9.6409374243,-0.2287478555,0.15069,-11.2071266916 67.589089469,3.9426,3.438,12.1236363414,0.132067636,0.15069,-19.521625573 52.410910531,4,3.5774,7.5486792315,0.132067636,0.15069,-19.521625573 37.589089469,4.0919,3.6968,9.6409374243,0.2287478555,0.15069,-11.2071266916 22.410910531,4.2113,3.7887,9.6409374243,-0.2287478555,0.15069,-11.2071266916 7.589089459,4.3506,3.8461,12.1236363414,0.132067636,0.15069,-19.521625573 67.589089469,4.5,3.866,12.1236363414,0.132067636,0.15069,-19.52162557 82.410910531,4.5575,4.0053,9.6409374243,-0.2287478555,0.15069,-11.2071266916 97.58908946,4.5774,4.1547,9.6409374243,0.2287478555,0.15069,-11.2071266916 112.410910531,4.5574,4.3041,12.1236363414,-0.132067636,0.15069,-19.52162557 127.589089469,4.5,4.4434,7.5486792315,-0.132067636,0.15069,-19.52162557 142.410910531,4.4081,4.5628,9.6409374243,-0.2287478555,0.15069,-11.2071266916 157.589089469,4.2887,4.6547,9.6409374243,0.2287478555,0.15069,-11.2071266916 172.410910531,4.1494,4.7121,7.5486792315,0.132067636,0.15069,-19.52162557 *eldon fecit MMXXIII Trilobe-E.pat
    1 point
  3. If this is indeed an assignment for school, LISP probably doesn't help the OP. It is called a breakout section, IIRC. Sketch is what I would use.
    1 point
  4. This was posted earlier, if we change the length to area would that work? Noting that this sums all the line lengths on a layer
    1 point
  5. Have a go, and see if you can get it to work - it is all there, but we can help you along the way and is a great way to learn
    1 point
  6. Converting to vla-object then using curve functions is also quite a bit slower. (setq e (car (entsel))) (setq o (vlax-ename->vla-object e)) (benchmark '((vlax-curve-getStartPoint e)(vlax-curve-getStartPoint o))) ;;;<Entity name: 1e9f2363150> ;;;#<VLA-OBJECT IAcadLWPolyline 000001e9df9c2dc8> Benchmarking ..................Elapsed milliseconds / relative speed for 32768 iteration(s): ;;; ;;; (vlax-curve-getStartPoint E).....1781 / 1.71 <fastest> ;;; (vlax-curve-getStartPoint O).....3047 / 1.00 <slowest> ;;; ;;;---- Benchmark Utility: In memory of Michael Puckett ---- ;;; ;;;; 3 forms loaded from #<editor "<Untitled-0> loading...">
    1 point
  7. Hopefully you'll learn from this. Anytime you download a lisp file add the link you downloaded it from commented out in the lisp file. It's usually the best location to ask for help like now. Not changing the name of the lisp makes it easier to search for online. Lenght of Each polyline by layerwise in table.LSP.
    1 point
  8. 3dwannab, I've tested this today several times and it works 100%. You have amazing skills sir! Thank you 3dwannab and Lee Mac for saving my job!
    1 point
  9. Here's something you could try. 1. Select the entire model and make it a block. 2. Make a copy of the block and move it X0,Y0,Z0. 3. Use the BEDIT command to work on the copy. When you save and close the block editor, the changes you made will update to the original model that's way out in space somewhere. 4. Once you're finished working, you can delete the copy and explode the original block. This is all hypothetical though. I've never had to do something like this, but it should work. I would keep a copy of the original file as backup though, in case something goes wrong. I would also routinely save and close the block editor every 10 minutes or so, and save the file. You don't want to work in the block editor for extended periods of time. I have run across issues where the editor gets overloaded or something and it refuses to save and close, which results in lost work. Another option would be to simply save a copy of the file and work in the copied file. You could move everything to the origin, do whatever work you need to do and then copy everything back to the original file and replace the original model. Or you could work in the original file, as Bigal mentioned. Just move everything to the origin to work on it and then move it back to the original location when you're done. You would just need to place some markers at the original location so you know exactly where to put the model back when you're done working.
    1 point
  10. It works! thank you very much!
    1 point
  11. Here's a mod of something LeeMac originally wrote. (vl-load-com) ;; ;; Select Blocks by same name ;; Updated by 3dwannab on 2022.03.30. ;; ;; I updated this on the 2022.03.30 to use the SELECTSIMILAR command by setting ;; the SELECTSIMILARMODE to 128 which is to select similar by name. ;; Along with a filter for the selection of blocks, after this it's pretty simple. ;; ;; Initial code was here by Lee Mac: http://www.theswamp.org/index.php?topic=49667.msg548516#msg548516 ;; (defun c:QSBlocks_Same (/ *error* acDoc def lst ss1 ss2 var_cmdecho var_osmode var_selectsimilarmode) (princ "Filter select all similar Blocks by name :\n") (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) (setvar 'selectsimilarmode var_selectsimilarmode) ) (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)) (setq var_selectsimilarmode (getvar 'selectsimilarmode)) (setvar 'cmdecho 0) (setvar 'osmode 0) ; Code by Lee Mac http://www.cadtutor.net/forum/showthread.php?92638-Simple-fix-%28LISP-noob%29-Syntax-problem&p=633824&viewfull=1#post633824 ;; Iterate over the block table and compile a list of xref blocks to exclude (while (setq def (tblnext "block" (not def))) (if (= 4 (logand 4 (cdr (assoc 70 def)))) (setq lst (vl-list* "," (cdr (assoc 2 def)) lst)) ) ) ;; Attempt to retrieve a selection of blocks (but not xrefs) (setq ss1 (ssget (cons '(0 . "INSERT") (if lst (vl-list* '(-4 . "<NOT") (cons 2 (apply 'strcat (cdr lst))) '((-4 . "NOT>"))))))) ;; Set selectsimilarmode to use the name of an object. (setvar 'selectsimilarmode 128) ;; If ss1 one is valid then do this (if ss1 (progn (vl-cmdf "_.selectsimilar" ss1 "") (setq ss2 (ssget)) ;; Create a new selection set for to zoom and reselect as the zoom objects will do this ;; (command "_.zoom" "_O" ss2 "") (sssetfirst nil ss2) (command "_.regen") (princ (strcat "\n: ------------------------------\n\t\t<<< " (itoa (sslength ss2)) (if (> (sslength ss2) 1) " <<< INSERTS objects" " <<< INSERT object") " selected\n: ------------------------------\n")) ) (princ "\n: ------------------------------\n\t\t*** Nothing selected ***\n: ------------------------------\n") ) (*error* nil) (princ) )
    1 point
  12. Like this? So first the material, then X,Y, then the rest. ;; @FILE extract data of blocks with blockname "TEST". Extract coordinates and attribute values. (vl-load-com) ; initialization ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; read attributes ;; Get Attribute Value - Lee Mac ;; Returns the value held by the specified tag within the supplied block, if present. ;; blk - [vla] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; Returns: [str] Attribute value, else nil if tag is not found. (defun LM:vl-getattributevalue ( blk tag ) (setq tag (strcase tag)) (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att))) (vlax-invoke blk 'getattributes)) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun export2file (data / fname file) (setq fname "C:/extbl.txt") (setq file (open fname "w")) ;; whrite all lines (foreach line data (write-line line file) ) (close file) (startapp "notepad.exe" fname) ) ;_ end of defun (defun c:extbl ( / ss i en obj data ip line_str material year status ) ;; Select the blocks (setq ss (ssget "X" '((0 . "INSERT") (2 . "TEST"); object Name ) ) ) (setq data (list)) ;; list of lines to be exported (setq i 0) (repeat (sslength ss) (setq en (ssname ss i) obj (vlax-ename->vla-object en) ) ;; read coordinates (setq ip (cdr (assoc 10 (entget en)))) ;; read attributes (setq material (LM:vl-getattributevalue obj "MATERIAL")) (setq year (LM:vl-getattributevalue obj "YEAR")) (setq status (LM:vl-getattributevalue obj "STATUS")) (princ "\n") ;; assemble the line (setq line_str (strcat material "," (rtos (nth 0 ip) 2 10) "," ;; 10 is the number of digits. Feel free to change the value (rtos (nth 1 ip) 2 10) "," year "," status )) (setq data (append data (list line_str ))) (setq i (+ i 1)) ) ;; export all (export2file data) (princ) )
    1 point
  13. Had this issue until recently, I've since come across a Lisp routine that removes all dynamic properties before issue. Still maintains all the blocks as blocks; and retains visibility properties, but removes all controls. We've now made this a standard practice before issuing DWG files to protect our content.
    1 point
×
×
  • Create New...