Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/17/2022 in all areas

  1. Forgot to add just take a existing drawing as a start and erase all objects but dont do a purge and add more to it, like Tombu use Lee's steal.
    2 points
  2. Don't know if you want metric or imperial, but I uploaded a zip with a full set of metric ones some years ago: https://www.cadtutor.net/forum/topic/62352-titleblock/?tab=comments#comment-514547
    1 point
  3. If your going to start from scratch here is a little trick to get the maximum print area. Once the page size is set create a viewport and use the fit option. This creates a viewport on the dashed lines in paper space. (the maximum print area) You now have something to snap to when drawing a rectangle. That rectangle will need to be offset in a small distance. Then just delete the viewport and larger rectangle. you can now create a title block within said rectangle.
    1 point
  4. Try this. works on text, mtext and tables ;;----------------------------------------------------------------------------;; ;; CREATE TABLE AND ADD SELECTED TEXT TO IT (defun c:AHxcol (/ k txtsz x pt1 numrows numcolumns rowheight colwidth ent doc curspace obj objtable col) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (setq curspace (vla-get-modelspace doc)) ; now do table (setq pt1 (vlax-3d-point (getpoint "\nPick point for top left hand of table: "))) (setq numcolumns (getint "Number of columns: ")) (setq txtsz (getreal "Text size: ")) (setq numrows 2) (setq rowheight (* 1.5 txtsz)) (setq colwidth (* 10 txtsz)) (setq objtable (vla-addtable curspace pt1 numrows numcolumns rowheight colwidth)) (vla-settext objtable 0 0 "TABLE") (setq x 0) (repeat numcolumns (vla-settext objtable 1 x (strcat "COLUMN " (itoa (setq x (1+ x))))) ) (setq objtable (vlax-ename->vla-object (entlast))) (vla-InsertRows objtable numrows txtsz 1) (setq col 0) (while (setq ent (entsel "Pick text : ")) (cond ((member (vla-get-objectname (setq obj (vlax-ename->vla-object (car ent)))) '( "AcDbMText" "AcDbText")) (progn (vla-put-color obj 1) (vla-settext objtable numrows col (vla-get-textstring obj)) (setq col (1+ col)) (if (= col numcolumns) (progn (setq col 0) (setq numrows (1+ numrows)) (vla-InsertRows objtable numrows (* txtsz 1.5) 1) ) ) ) ) ((eq (vla-get-objectname (setq obj (vlax-ename->vla-object (car ent)))) "AcDbTable") (setq x (_hit-test (cadr ent) obj)) (setq COLOBJ (vla-getinterfaceobject (vlax-get-acad-object) "AutoCAD.AcCmColor.16")) (vla-put-colorindex COLOBJ 1) (vla-SetCellContentColor obj (car x) (cadr x) COLOBJ) (vla-settext objtable numrows col (vla-getText obj (car x) (cadr x))) (setq col (1+ col)) (if (= col numcolumns) (progn (setq col 0) (setq numrows (1+ numrows)) (vla-InsertRows objtable numrows (* txtsz 1.5) 1) ) ) ) ) ) (vla-SetTextHeight objtable (+ acDataRow acHeaderRow acTitleRow) txtsz) (vla-SetAlignment objtable acDataRow acMiddleCenter) (setq x -1) (repeat numcolumns (if (/= (vla-gettext objtable numrows (setq x (1+ x))) "") (setq k 1)) ) (if (eq k 1) (progn) (vla-deleterows objtable numrows numrows) ) (vlax-release-object objtable) (princ) ) ;;----------------------------------------------------------------------------;; ;; FIND ROW AND COLUMN OF SELECTED TEXT IN TABLE (defun _hit-test (pt obj / vd) (setq pt (vlax-3D-point (trans pt 1 0)) vd (vlax-3D-point (trans (getvar 'VIEWDIR) 1 0)) ) (if (eq :vlax-true (vla-hittest obj pt vd 'r 'c)) (list r c) ) )
    1 point
  5. this is a simple routine to put in numbers into the Collatz conjecture. https://en.wikipedia.org/wiki/Collatz_conjecture Command - collatz : graphic mode, like the gif above. - collatztxt : text mode, like below Command: COLLATZTXT input start number : 12302198909 12302198909>36906596728>18453298364>9226649182>4613324591>13839973774>6919986887>20759960662>10379980331>31139940994>15569970497>46709911492>23354955746>11677477873>35032433620>17516216810>8758108405>26274325216>13137162608>6568581304>3284290652>1642145326>821072663>2463217990>1231608995>3694826986>1847413493>5542240480>2771120240>1385560120>692780060>346390030>173195015>519585046>259792523>779377570>389688785>1169066356>584533178>292266589>876799768>438399884>219199942>109599971>328799914>164399957>493199872>246599936>123299968>61649984>30824992>15412496>7706248>3853124>1926562>963281>2889844>1444922>722461>2167384>1083692>541846>270923>812770>406385>1219156>609578>304789>914368>457184>228592>114296>57148>28574>14287>42862>21431>64294>32147>96442>48221>144664>72332>36166>18083>54250>27125>81376>40688>20344>10172>5086>2543>7630>3815>11446>5723>17170>8585>25756>12878>6439>19318>9659>28978>14489>43468>21734>10867>32602>16301>48904>24452>12226>6113>18340>9170>4585>13756>6878>3439>10318>5159>15478>7739>23218>11609>34828>17414>8707>26122>13061>39184>19592>9796>4898>2449>7348>3674>1837>5512>2756>1378>689>2068>1034>517>1552>776>388>194>97>292>146>73>220>110>55>166>83>250>125>376>188>94>47>142>71>214>107>322>161>484>242>121>364>182>91>274>137>412>206>103>310>155>466>233>700>350>175>526>263>790>395>1186>593>1780>890>445>1336>668>334>167>502>251>754>377>1132>566>283>850>425>1276>638>319>958>479>1438>719>2158>1079>3238>1619>4858>2429>7288>3644>1822>911>2734>1367>4102>2051>6154>3077>9232>4616>2308>1154>577>1732>866>433>1300>650>325>976>488>244>122>61>184>92>46>23>70>35>106>53>160>80>40>20>10>5>16>8>4>2>1 code is below ; COLLATZ - 2022.06.17 exceed ; this is a simple routine to plug in numbers into the "Collatz conjecture" ; ; Command List ; collatztxt - Only text output. When you enter a number, it does a Colatz conjecture until it reaches 1. ; collatz - run collatz guesses by 100, starting at 2 It rotates +5 degrees for odd numbers and -5 degrees for even numbers. ; It asks if you want to continue every 100 in case of freezing. (defun c:collatz ( / a ) (setq a 1) (while (getstring "\n continue? (SpaceBar - Continue / ESC - End) - ") (repeat 100 (ex:collatzgr a) (setq a (+ a 1)) ) (princ "\n collatz graph done - from ") (princ (- a 100)) (princ " to ") (princ a) (command "_.Zoom" "_E") ) (princ) ) (defun c:collatztxt ( / n ) (setq n (getreal "\n input start number : ")) (princ (strcat "\n " (rtos n 2 0))) (while (> n 1) (cond ((= (rem n 2) 1) (setq n (+ (* n 3) 1)) (princ (strcat ">" (rtos n 2 0))) ) ((= (rem n 2) 0) (setq n (/ n 2)) (princ (strcat ">" (rtos n 2 0))) ) ) ) (princ) ) (defun EX:COLLATZGR ( n / mspace basedeg deltadeg basept pt2 collatzline ) (vl-load-com) (defun dtr (x) (* pi (/ x 180.0)) ) (defun rtd (x) (* x (/ 180.0 pi)) ) (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq basedeg 90) (setq deltadeg 5) (setq basept (list 0 0 0)) ;(princ (strcat "\n " (rtos n 2 0))) (while (> n 1) (cond ((= (rem n 2) 1) (setq n (+ (* n 3) 1)) (setq pt2 (polar basept (dtr basedeg) n)) (setq basedeg (+ basedeg deltadeg)) (setq collatzline (vla-addline mspace (vlax-3d-point basept)(vlax-3d-point pt2))) (setq basept pt2) ;(princ (strcat ">" (rtos n 2 0))) ) ((= (rem n 2) 0) (setq n (/ n 2)) (setq pt2 (polar basept (dtr basedeg) n)) (setq basedeg (- basedeg deltadeg)) (setq collatzline (vla-addline mspace (vlax-3d-point basept)(vlax-3d-point pt2))) (setq basept pt2) ;(princ (strcat ">" (rtos n 2 0))) ) ) ) (princ) )
    1 point
  6. Coming back to this one again, this version uses the same idea I had above but closes each dialogue box and opens a new one which gets past the 8 children problem There are 4 defuns in this, one for each tab (create more or less as you want), and currently they return the variable 'MyTab'. If you want to keep any variables entered into a dialogue I would have 'MyTab' as a list, the first item being the selected next tab to go to, and after that include in the list all the other variables, perhaps for the full dialogue box, and update that as the user selects controls. Am sure you can work out passing numbers backwards and forwards and repopulating the dialogue boxes with that. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun Tab1 ( / dcl1 des1 dch1 x MyTab) ;;;DCL 1 ;;DCL on the fly: Ideas by Lee Mac and Cadtutor forums ;;create DCL pop up box (if (and (setq dcl1 (strcat (getvar "TEMPPREFIX") "DCLTab1.dcl")) (setq des1 (open dcl1 "w")) (foreach x '( " pass : dialog" " {" " key = \"Lispdialoguebox\";" " label = \"A Dialogue Box\";" " spacer;" " : column { width=80;" " : row {" " : button { key = \"Tab1\"; label = \"Tab1\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " : button { key = \"Tab2\"; label = \"Tab2\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " : button { key = \"Tab3\"; label = \"Tab3\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " : button { key = \"Tab4\"; label = \"Tab4\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " spacer;" " }" " }" " : boxed_column { width=80; label = \"A TITLE HERE 'Tab 1'\";" " : row { width=80; alignment = centered;" " : column {width = 20; alignment = centered;" " :row {alignment = bottom;" " : text { key = \"text1-a\"; label = \"Lets Make DCL!\"; width = 20; alignment = right;}" " }" " : row {width = 40; alignment = left;" " : text { key = \"text1-b\"; label = \"and put all the fun bits here\"; width = 20; alignment = right;}" " }" " }" " }" " }" " : boxed_column { width=80; alignment = left;" " : row {" " : column {width = 18; alignment = centered;" " : button { key = \"accept\"; label = \"OK\"; is_default = true; is_cancel = true; fixed_width = true; width = 15; }" " }" " : column {width = 18; alignment = centered;" " : button { key = \"cancel\"; label = \"Cancel\"; is_default = false; is_cancel = true; fixed_width = true; width = 15; }" " }" " }" " }" " }" ) (write-line x des1) ) (not (setq des1 (close des1))) (< 0 (setq dch1 (load_dialog dcl1))) (new_dialog "pass" dch1) ) ;;End of DCL pop up box definition (progn ;;makes a pop-up list box (action_tile "Tab1" "(Setq MyTab \"Tab1\")(term_dialog)(done_dialog 1)") (action_tile "Tab2" "(Setq MyTab \"Tab2\")(term_dialog)(done_dialog 1)") (action_tile "Tab3" "(Setq MyTab \"Tab3\")(term_dialog)(done_dialog 1)") (action_tile "Tab4" "(Setq MyTab \"Tab4\")(term_dialog)(done_dialog 1)") (action_tile "accept" "(done_dialog 1)(term_dialog)") (action_tile "cancel" "(done_dialog 0)(term_dialog)") (start_dialog) ) ;;end of DCL1 'and' above (princ "\nError. Unable to load dialogue box.") ) ;;end of DCL1 'if' above (vl-file-delete dcl1) ;;delete the temp DCL file MyTab ) ; end defun tab 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun Tab2 ( / dcl2 des2 dch2 x MyTab) (if (and (setq dcl2 (strcat (getvar "TEMPPREFIX") "DCLTab2.dcl")) (setq des2 (open dcl2 "w")) (foreach x '( " pass : dialog" " {" " key = \"Lispdialoguebox\";" " label = \"Popped Up to say Hello\";" " spacer;" " : column { width=80;" " : row {" " : button { key = \"Tab1\"; label = \"Tab1\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " : button { key = \"Tab2\"; label = \"Tab2\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " : button { key = \"Tab3\"; label = \"Tab3\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " : button { key = \"Tab4\"; label = \"Tab4\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " spacer;" " }" " }" " : boxed_column { width=80; label = \"A TITLE HERE 'Tab 2'\";" " : row { width=80; alignment = centered;" " : column {width = 20; alignment = centered;" " :row {alignment = bottom;" " : text { key = \"text1-a\"; label = \"Aha!! Tab 2!!\"; width = 20; alignment = right;}" " }" " : row {width = 40; alignment = left;" " : text { key = \"text1-b\"; label = \"put more fun bits here\"; width = 20; alignment = right;}" " }" " }" " }" " }" " : boxed_column { width=80; alignment = left;" " : row {" " : column {width = 18; alignment = centered;" " : button { key = \"accept\"; label = \"OK\"; is_default = true; is_cancel = true; fixed_width = true; width = 15; }" " }" " : column {width = 18; alignment = centered;" " : button { key = \"cancel\"; label = \"Cancel\"; is_default = false; is_cancel = true; fixed_width = true; width = 15; }" " }" " }" " }" " }" ) (write-line x des2) ) (not (setq des2 (close des2))) (< 0 (setq dch2 (load_dialog dcl2))) (new_dialog "pass" dch2) (princ "Tab 2 Loaded") ) ;;End of DCL pop up box definition (progn ;;makes a pop-up list box (action_tile "Tab1" "(Setq MyTab \"Tab1\")(term_dialog)(done_dialog 1)") (action_tile "Tab2" "(Setq MyTab \"Tab2\")(term_dialog)(done_dialog 1)") (action_tile "Tab3" "(Setq MyTab \"Tab3\")(term_dialog)(done_dialog 1)") (action_tile "Tab4" "(Setq MyTab \"Tab4\")(term_dialog)(done_dialog 1)") (action_tile "accept" "(done_dialog 1)(term_dialog)") (action_tile "cancel" "(done_dialog 0)(term_dialog)") (start_dialog) ) ;;end of DCL2 'and' above (princ "\nError. Unable to load dialogue box.") ) ;;end of DCL2 'if' above (vl-file-delete dcl2) ;;delete the temp DCL file MyTab ) ; end defun tab 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun Tab3 ( / dcl3 des3 dch3 x MyTab) (if (and (setq dcl3 (strcat (getvar "TEMPPREFIX") "DCLTab3.dc3")) (setq des3 (open dcl3 "w")) (foreach x '( " pass : dialog" " {" " key = \"Lispdialoguebox\";" " label = \"The popped away again\";" " spacer;" " : column { width=80;" " : row {" " : button { key = \"Tab1\"; label = \"Tab1\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " : button { key = \"Tab2\"; label = \"Tab2\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " : button { key = \"Tab3\"; label = \"Tab3\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " : button { key = \"Tab4\"; label = \"Tab4\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " spacer;" " }" " }" " : boxed_column { width=80; label = \"A TITLE HERE 'Tab 3'\";" " : row { width=80; alignment = centered;" " : column {width = 20; alignment = centered;" " :row {alignment = bottom;" " : text { key = \"text1-a\"; label = \"Now your talking, Tab 3!!\"; width = 20; alignment = right;}" " }" " : row {width = 40; alignment = left;" " : text { key = \"text1-b\"; label = \"good this,\"; width = 20; alignment = right;}" " }" " }" " }" " }" " : boxed_column { width=80; alignment = left;" " : row {" " : column {width = 18; alignment = centered;" " : button { key = \"accept\"; label = \"OK\"; is_default = true; is_cancel = true; fixed_width = true; width = 15; }" " }" " : column {width = 18; alignment = centered;" " : button { key = \"cancel\"; label = \"Cancel\"; is_default = false; is_cancel = true; fixed_width = true; width = 15; }" " }" " }" " }" " }" ) (write-line x des3) ) (not (setq des3 (close des3))) (< 0 (setq dch3 (load_dialog dcl3))) (princ "Tab 3 Loaded") (new_dialog "pass" dch3) ) ;;End of DCL pop up box definition (progn ;;makes a pop-up list box (action_tile "Tab1" "(Setq MyTab \"Tab1\")(term_dialog)(done_dialog 1)") (action_tile "Tab2" "(Setq MyTab \"Tab2\")(term_dialog)(done_dialog 1)") (action_tile "Tab3" "(Setq MyTab \"Tab3\")(term_dialog)(done_dialog 1)") (action_tile "Tab4" "(Setq MyTab \"Tab4\")(term_dialog)(done_dialog 1)") (action_tile "accept" "(done_dialog 1)(term_dialog)") (action_tile "cancel" "(done_dialog 0)(term_dialog)") (start_dialog) ) ;;end of DCL3 'and' above (princ "\nError. Unable to load dialogue box.") ) ;;end of DCL3 'if' above (vl-file-delete dcl3) ;;delete the temp DCL file MyTab ) ; end defun tab 3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun Tab4 ( / dcl4 des4 dch4 x MyTab) (if (and (setq dcl4 (strcat (getvar "TEMPPREFIX") "DCLTab4.dcl")) (setq des4 (open dcl4 "w")) (foreach x '( " pass : dialog" " {" " key = \"Lispdialoguebox\";" " label = \"This is Tab 4 by the way\";" " spacer;" " : column { width=80;" " : row {" " : button { key = \"Tab1\"; label = \"Tab1\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " : button { key = \"Tab2\"; label = \"Tab2\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " : button { key = \"Tab3\"; label = \"Tab3\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " : button { key = \"Tab4\"; label = \"Tab4\"; is_default = false; is_cancel = true; fixed_width = true; width = 20;}" " spacer;" " }" " }" " : boxed_column { width=80; label = \"A TITLE HERE 'Tab 4'\";" " : row { width=80; alignment = centered;" " : column {width = 20; alignment = centered;" " :row {alignment = bottom;" " : text { key = \"text1-a\"; label = \"Look who'se talkng!!\"; width = 20; alignment = right;}" " }" " : row {width = 40; alignment = left;" " : text { key = \"text1-b\"; label = \"to you. Anopther Tab!!\"; width = 20; alignment = right;}" " }" " }" " }" " }" " : boxed_column { width=80; alignment = left;" " : row {" " : column {width = 18; alignment = centered;" " : button { key = \"accept\"; label = \"OK\"; is_default = true; is_cancel = true; fixed_width = true; width = 15; }" " }" " : column {width = 18; alignment = centered;" " : button { key = \"cancel\"; label = \"Cancel\"; is_default = false; is_cancel = true; fixed_width = true; width = 15; }" " }" " }" " }" " }" ) (write-line x des4) ) (not (setq des4 (close des4))) (< 0 (setq dch4 (load_dialog dcl4))) (princ "Tab 4 Loaded") (new_dialog "pass" dch4) ) ;;End of DCL pop up box definition (progn ;;makes a pop-up list box (action_tile "Tab1" "(Setq MyTab \"Tab1\")(done_dialog 1)") (action_tile "Tab2" "(Setq MyTab \"Tab2\")(done_dialog 1)") (action_tile "Tab3" "(Setq MyTab \"Tab3\")(done_dialog 1)") (action_tile "Tab4" "(Setq MyTab \"Tab4\")(done_dialog 1)") (action_tile "accept" "(done_dialog 1)") (action_tile "cancel" "(done_dialog 0)") (start_dialog) ) ;;end of DCL4 'and' above (princ "\nError. Unable to load dialogue box.") ) ;;end of DCL4 'if' above (vl-file-delete dcl4) ;;delete the temp DCL file MyTab ;;change this to a list with all variables in it. Repopulate tab when it is opened again ) ; end defun tab 4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:testthis ( / ) (setq MyTab (Tab1)) (setq Done "Not") (while (= Done "Not") (if (= MyTab nil)(setq Done "Yes")) (if (/= MyTab nil)(setq MyTab (eval (read (strcat "(" MyTab ")"))) ) ) ); end while
    1 point
  7. might provide a little help @ILoveMadoka ;;----------------------------------------------------------------------------;; ;; Creates Viewport outline and moves it to Model space (defun C:VP2M (/ SS vp elist MiscOn cen c40 c41 LL UR) (if (setq SS (ssget "_X" (list '(0 . "viewport") (cons 410 (getvar 'ctab))))) (foreach vp (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (setq elist (entget vp)) (if (> (cdr (assoc '69 elist)) 1) ; skip display viewport (progn (if (= (cdr (assoc '68 elist)) 0) ; is viewport active? (progn (setq MiscOn 'NO) (vl-cmdf "._Mview" "_on" "_si" vp) ; activate viewport ) ; progn (setq MiscOn 'YES) ) ; if (setq cen (cdr (assoc '10 elist)) c40 (cdr (assoc '40 elist)) ;length c41 (cdr (assoc '41 elist)) ;width LL (list (- (car cen) (/ c40 2)) (- (cadr cen) (/ c41 2))) UR (list (+ (car cen) (/ c40 2)) (+ (cadr cen) (/ c41 2))) ) (vl-cmdf "_.Pspace") (vl-cmdf "_.Rectangle" LL UR) (vl-cmdf "_.Chspace" "_Last" "") (vl-cmdf "_.Pspace") (if (eq MiscOn 'NO) (vl-cmdf "_.Mview" "_off" "_si" vp) ; deactivate viewport ) ) ) ) ) ;(setvar 'Tilemode 1) ;go to model space (princ)
    1 point
  8. I have a few basic templates that include blocks, styles, layers and layer states we use for all our drawings. Everything else like page setups, layouts with title blocks and additional text & dimension styles are imported using Lee Mac's Steal from Drawing macros. Too many sizes & types of layouts & title blocks to include them all in a new drawing from a template.
    1 point
×
×
  • Create New...