Jump to content

Search the Community

Showing results for tags 'mtext editing'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions

Categories

  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Found 2 results

  1. Hi Everyone, I am trying to create an AutoLISP that will replace and/or automatically update an MText field (which in my case are the amendments for a drawing) in the Layouts tab for a series of drawings. The Lisp uses Lee Mac's Object DBX Wrapper and his get files routines (Thank you btw :)) to obtain the drawings and supply the function to each drawing. I am pretty new to Visual Lisps and only understand the basic functions like the vla-get-<item>. I am able to update the first drawing/opened drawing, however cannot seem to get the lisp to loop for each drawing selected. I suspect that it has something to do with vlax-for function but i do not completely understand it, especially when multiple drawings are being evaluated. Autolisp Code: ;--------------------------------EDIT BOX SAVE VARIABLES-----------------------------------; (Defun saveVars () (setq Date (get_tile "Date")) (setq Initials (get_tile "Initials")) (setq Subject (get_tile "Subject")) (setq Rev1 (atoi (get_tile "Rev1"))) (setq Prelim (atoi (get_tile "Prelim"))) (setq Tender (atoi (get_tile "Tender"))) ) ;-------------------------------------LOAD FILES------------------------------------------; (defun LoadFiles (a) (cond ((= a 1) (setq flst (LM:getfiles "select Drawings" nil "dwg"))) ) ) ;-----------------------------EDIT BOX LOAD AND FUNCTIONS----------------------------------; (defun C:Editbox ( ) (vl-load-com) (if (not (setq dcl_id (load_dialog "DCL_DCL_Editbox.dcl"))) (progn (alert "The DCL file could not be loaded.") (exit) ) (progn (if (not (new_dialog "DCL_Editbox" dcl_id)) (progn (alert "The DCL_DCL_Editbox could not be found inside the DCL file") (exit) ) (progn (action_tile "but1" "(LoadFiles 1)") (action_tile "accept" "(saveVars) (done_dialog 2)") (action_tile "cancel" "(done_dialog 1)") (setq ddiag (start_dialog)) (unload_dialog dcl_id) (if (= ddiag 1) (progn (print "Editbox cancelled!") (exit) ) ) (if (and (= ddiag 2) (and (= prelim 1) (= tender 1))) (exit) (LM:ODBX 'SC:T2 flst t) ) ) ) ) ) (princ) ) ;--------------------------------REWRITE AMENDMENTS FUNCTION-----------------------------------; (defun SC:T2 ( doc / ss1 lst2 lst RstrP StrPP RevNP RstrT StrPT RevNT) (vl-load-com) (vlax-for layout (vla-get-layouts doc) (vlax-for object (vlax-get (vla-get-activedocument (vlax-get-acad-object)) 'PaperSpace ) (if (= "AcDbMText" (vla-get-objectname object)) (setq lst (cons object lst)) ) (setq lst2 (car lst)) ) lst (setq ss1 (vlax-get-property lst2 'Textstring)) (progn (cond ((and (= rev1 1) (= Prelim 1)) (progn (vla-put-textstring lst2 (strcat "\\pxi-15,l15,tc2,c7,c12,15;\tP1\t" Date "\t" Initials "\t" Subject)) ) ) ((and (= rev1 1) (= tender 1)) (progn (vla-put-textstring lst2 (strcat "\\pxi-15,l15,tc2,c7,c12,15;\t00\t" Date "\t" Initials "\t" Subject)) ) ) ((= Prelim 1) (progn (setq RstrP (vl-list->string (reverse (vl-string->list ss1)))) (if (setq StrPP (vl-string-position (ascii "{") RstrP)) (setq RevNP (substr (vl-list->string (reverse (vl-string->list (substr RstrP (- StrPP 2) 2)))) 2 1)) (setq RevNP "1")) (vla-put-textstring lst2 (strcat ss1 "\\P{\t" (strcat "P" (rtos (+ (distof RevNP 2) 1) 2 3)) "\t" Date "\t" Initials "\t" Subject "}")) ) ) ((= Tender 1) (progn (setq RstrT (vl-list->string (reverse (vl-string->list ss1)))) (if (equal (vl-string-search "00" ss1) nil) (progn (vla-put-textstring lst2 (strcat ss1 "\\P{\t00\t" Date "\t" Initials "\t" Subject "}")) (exit) ) (if (setq StrPT (vl-string-position (ascii "{") RstrT)) (setq RevNT (substr (vl-list->string (reverse (vl-string->list (substr RstrT (- StrPT 2) 2)))) 2 1)) (setq RevNT "1")) ) (vla-put-textstring lst2 (strcat ss1 "\\P{\t" (strcat "0" (rtos (+ (distof RevNT 2) 1) 2 3)) "\t" Date "\t" Initials "\t" Subject "}")) ) ) ) ) (princ) ) ) ;--------------------------------GET TAB SPACING-----------------------------------; (defun _splitwords (str del / pos lst4 lst3 ss) (if (setq pos (vl-string-search del str)) (cons (substr str 1 pos) (_splitwords (substr str (+ pos 2))del)) (list str) ) ) (vlax-for obj2 (vlax-get (vla-get-activedocument (vlax-get-acad-object)) 'PaperSpace ) (if (= "AcDbMText" (vla-get-objectname obj2)) (setq lst4 (cons obj2 lst4)) ) (setq lst3 (car lst4)) ) lst4 (setq str (vlax-get-property lst3 'Textstring)) (_splitwords str "\t") DCL Code: DCL_Editbox : dialog { label = "Amendments Update"; : column { : boxed_column { : edit_box { key = "Date"; label = "Enter Date :"; edit_width = 5; value = "01.01.24"; initial_focus = true; } : edit_box { key = "Initials"; label = "Enter Initials :"; edit_width = 5; value = "XXX"; } : edit_box { key = "Subject"; label = "Enter Subject :"; edit_width = 25; value = "PRELIMINARY"; } } : boxed_column { : toggle { key = "Rev1"; label = "Check Box if this is First Revision."; value = "0"; } : toggle { key = "Prelim"; label = "Check Box if this is Preliminary."; value = "0"; } : toggle { key = "Tender"; label = "Check Box if this is Tender or Construction Issue."; value = "0"; } } : boxed_column { : button { key = "but1"; label = "Select Files"; is_default = false; } } : boxed_row { :button { key = "accept"; label = " Okay "; is_default = true; } : button { key = "cancel"; label = " Cancel "; is_default = false; is_cancel = true; } } } } I have found very little information on obtain MText on its own, not in a block, through ODBX and visual lisps; and even tried to wrap my head around Lee Mac's batch find and replace but could not quite work it out. Any help would be appreciated and if you need any additional info let me know. Thanks, Sol. P.S. This is my first post so apologies for any formatting errors and also thank you to everyone that has already helped with this lisp by providing functions on other topics/forums that have also been used here. Amendment Updates.lsp DCL_DCL_Editbox.dcl ODBX Wrapper.lsp Get Files.lsp
  2. Hi all, i am using autocad 2011, in that i have some MTEXT's , i am trying to make them at same height & same font, i am selecting the all fonts & then properties & then making all height "3" & font style "arial" but if i double clicked on text it's showing me "1.37" height & "calibri" font
×
×
  • Create New...