Leaderboard
Popular Content
Showing content with the highest reputation on 07/05/2023 in all areas
-
That is spot on! Exactly what I was looking for! Gonna have a play around at home tonight - try and learn a bit. Thanks again lads Ash1 point
-
OK - something isn't working quite right in the formatting (it was when I tested it yesterday - must had had something hanging about that I hadn't noticed) - I'll fix it and edit here to let you know EDIT: I've updated the code above, I'd taken out a line last night for the cell colours, forgot to add it back in again (but in testing my CAD had that line loaded into it so never noticed, whoops!) It should be good to go now - have a look, work it out and then shout to say what changes you want - bigAls post has a lot of good formatting stuff in there too1 point
-
I do not believe Save As has a PDF option. Please explain what you are doing in detail, Export to PDF, Plotting DWG to PDF, etc. Is this happening on all drawings?1 point
-
1 point
-
Another example for a table. This modifies the width and height of the cells, the numbers are large as it was done as a response to a post. defun c:mktblexample ( / ) (setq txtht 120) (setq row 3 col 3) (Setq curspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq sp (vlax-3d-point (getpoint "pick a point for table "))) (setq objtable (vla-addtable curspace sp row col 200 500)) (vla-SetTextHeight Objtable acDataRow txtht) (vla-SetTextHeight Objtable acHeaderRow (* txtht 1.2)) (vla-SetTextHeight Objtable acTitleRow (* txtht 1.5)) (vla-put-VertCellMargin Objtable (* txtht 0.5)) (vla-put-HorzCellMargin Objtable (* txtht 0.5)) (vla-Setcolumnwidth Objtable 0 1800) (vla-Setcolumnwidth Objtable 1 1800) (vla-Setcolumnwidth Objtable 2 1800) (vla-SetTextHeight custObj acDataRow txtht) (vla-SetTextHeight custObj acHeaderRow (* txtht 1.2)) (vla-SetTextHeight custObj acTitleRow (* txtht 1.5)) (vla-SetAlignment Objtable (+ acDataRow acHeaderRow acTitleRow) acMiddleCenter) (vla-settext objtable 0 0 "LENGTH TABLE") (vla-settext objtable 1 0 "Length") (vla-settext objtable 1 1 "Count") (vla-settext objtable 1 2 "Layer name") (princ) ) next step is use insertrows to add more rows (vla-insertrows objtable numrows txtht 1) ; add 1 row (vla-settext objtable numrows 0 (rtos val 2 0))1 point
-
Have a go at what you can but try this. Command is gaps (change to suit your self) Will need some thinking to get the table formatting - not something I usually do a lot with. I am thinking at the end of gaps it creates this table the simplest solution might be create the table and then modify it. I have put in some table formatting stuff for you to play with, enjoy (defun c:gaps ( / textlist tablelist smaller larger) (setq textlist (c:TextList)) ; runs c:TextList to select numbers ;;The result from (c:TextList) is saved as a list, textlist (setq tablelist (list (list "Hole Diameter" "" "Centres"))) ; Table Header Row detail ;;tablelist is a list for each row in the table. Above is for the header row. ;;The number of items in this defines row the table columns ;; Text goes in between "..." and blank columns are "" (setq smaller (car textlist)) ; Get the first number in textlist (the 'smaller' one) (setq acount 1) ; a counter (while (< acount (length textlist) ) ; loop through the texts (setq larger (nth acount textlist)) ; getrthe second number ('larger') (setq difference (- (atof larger) (atof smaller))) ; minus. atof: the texts are strings not numbers (setq tablelist (append tablelist ; append to the tablelist results list ;; These 2 lines populate the table data list (list (list smaller "" "")) ; add in the smaller number in te first column, the other 2 columns are "" (list (list "" "" (rtos difference))) ; add the next row for difference. RTOS since result is a number not string )) ; (setq smaller larger) ; make the larger number now the smaller number (setq acount (+ acount 1)) ; increase the counter ) ; end while ; end the while loop (setq tablelist (append tablelist (list (list smaller "" "")) )) ;add in the last row, the last larger number ;Remember to keep this foramt as 'smaller' above (UnsTable tablelist) ; create the table using the list tablelist for the row data tablelist ) (defun UnsTable ( refs / ss name ref insPt table row acounter MyColumns) ; refs: List item for each row ; just a typo (vl-load-com) ; load vl- functions ;;this function used 'refs' as the data for each line (setq MyColumns (length (car refs))) ; work out number of colums based on 1st data list in refs (or *acdoc* (setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object))) ) ; get document reference (setq insPt (trans (getpoint "\nInsertion point: ") 1 0)) ; ask user for insert point (setq table (vla-addtable ; add table (vla-get-modelspace *acdoc*) ; put it in modelspace (vlax-3d-point insPt) ; at this insertion point (+ 2 (length refs)) ; number of rows (including title and header) MyColumns ; number of colums 220 ; cell height 1200 ; row width ) ) ;;;Formatting ;;;Cell margins (vla-put-horzcellmargin table 4.0) (vla-put-VertCellMargin table 4.0) ;;override column widths (vla-setcolumnwidth table 1 500) ;; Set the text height for the Title, Header and Data rows (vla-SetTextHeight table acTitleRow 187.5) (vla-SetTextHeight table (+ acDataRow acHeaderRow) 125) ;; Set the text style (vla-SetTextStyle table (+ acDataRow acHeaderRow acTitleRow) "Standard") ;;; Set the alignment for the Data, Header, and Title rows ; have to do individually? (vla-SetAlignment table acHeaderRow acMiddleCenter) (vla-SetAlignment table acTitleRow acMiddleCenter) (vla-SetAlignment table acDataRow acMiddleCenter) ; top middle bottom : left centre right ;;; Table Colours ;;; Odd colours used as deonstration for the method (setq col (vla-get-truecolor table)) (vla-put-colormethod col acColorMethodByRGB) (vla-SetRGB col 225 220 225) (vla-SetBackgroundColor table (+ acTitleRow acHeaderRow) col) (vla-SetRGB col 250 250 245) (vla-SetBackgroundColor table acDataRow col) ; data row background colours - full row (vla-SetRGB col 250 250 250) (vla-SetGridColor table (+ acHorzTop acHorzInside) acDataRow col) ; grid colours (vla-put-TitleSuppressed table :vlax-false) (vla-put-HeaderSuppressed table :vlax-false) ;;End formatting ;;These limes populate the table ;;Example: (vla-setText table Row Column Text) ;;'table' from a setq above ;;This line is the table title, "Holes" (vla-setText table 0 0 "Holes") ; table title ; set in column 0, row 0 (LISP count from as the first number) (setq row 1) ; a counter, assuning header row is sent with refs data, the first data row is row 1 ;;Loop through the list of text selected (foreach item refs ; loop through rows (setq acounter 0) ; a counter for columns (while (< acounter MyColumns) ; loop through columns (number defined by 1st in data ref.) ;;write the text to the cell (vla-settext table row acounter (nth acounter item)) ; set cell data (setq acounter (+ acounter 1)) ) (setq row (1+ row)) ) ; end foreach (princ) ) (defun c:TextList ( / ss eov entlist texts Mytext) (defun EntorValue ( MSG / EndLoop sel MyEnt MyValue enta entb pt) (princ MSG) (setq MyValue "") (setq MyEnt (list)) (setq EndLoop "No") (while (= EndLoop "No") (setq grsel (grread nil 4 2)) (setq sela (car grsel)) (if (or (= sela 2)(= sela 3) ) ; text entry or mouse click (setq sel (nth 1 grsel)) ) (if (= (type sel) 'LIST) (progn (setq MyEnt (nentselp sel)) (if (= nil MyEnt) (Princ "\nMissed! Try again. Select text or enter a value: ") (setq EndLoop "Yes") ) ; end if ) ; end progn (progn ; for text entry (if (= sel 13) ; enter (progn (setq EndLoop "Yes") ) ; end progn ) ; end if ) ; end progn ) ; end if list ) ; end while (if ( = (length MyEnt) 0) (progn MyValue ) ; end progn (progn ;;GetEnt code (setq enta (car MyEnt)) (setq pt (cdr (assoc 10 (entget enta))) ) ;;fix for nenset or entsel requirements (setq entb (last (last (nentselp pt)))) ;; use sel? (if (and (/= entb nil) (/= (type entb) 'real) ) (progn (if (wcmatch (cdr (assoc 0 (entget entb))) "ACAD_TABLE,*DIMENSION,*LEADER")(setq enta entb)) ) ) (setq MyEnt enta) MyEnt ) ; end progn ) ; end if ) ; end defun (setq texts (list)) (while (/= (setq eOv (entorvalue "\nSelect Text or exit: ")) "") (if (= (type eOv) 'ENAME) (progn (setq entlist (entget eOv)) (if (= (cdr (assoc 0 entlist)) "DIMENSION")(setq Mytext (cdr (assoc 42 entlist))) ) (if (or (= (cdr (assoc 0 entlist)) "TEXT")(= (cdr (assoc 0 entlist)) "MTEXT")) (setq Mytext (cdr (assoc 1 entlist))) ) (princ Mytext) (setq texts (append texts (list Mytext))) ) ; end progn (progn ) ; end progn ) ; end if ) ; end while texts ; return texts list )1 point
-
I've always used ScaleListDel by Steve Johnson http://www.cadforum.cz/cadforum_en/download.asp?fileID=724 You can set up as many different ones as you like. Commands and descriptions are in the header, examples are included to use or as a reference.1 point