+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Forum Newbie
    Using
    AutoCAD 2008
    Join Date
    Dec 2015
    Posts
    7

    Default Batch Script / VBA - 512 Drawings

    Registered forum members do not see this ad.

    Hi guys, first of all thanks for taking the time to ready my post. Life is busy but so many people out there make a real effort to help other people and I really appreciate it.

    Secondly, I've got what seems like a huge challenge to overcome. I am not proficient with script files or vba or any type of programming for that matter. I am merely an engineer in need of some stellar assistance.

    I have in my possession 512 client autocad drawings (ver.200 that require some manipulation (details to follow) to prepare the drawings for a substantial control system migration. Thankfully the preparation works that are required are fairly typical across the full suite of drawings. The preparation scope includes, but not limited to, scaling the full contents of the drawing in model space to fit snugly into an A2 drawing border, deleting the existing drawing border and inserting a new drawing border.

    My first question is this. How do I execute this scope of preparation works in the most time efficient manner? The process doesn't have to be pretty and I just want the 512 processed drawings at the end of the day (not literally!)

    Any pointers would be greatly appreciated. I've attached an example of the client drawing and also the new drawing border for information.

    Thanks in advance.

    Test_Loop.dwgA2_Border.dwg

  2. #2
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro K4200, 4GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2018
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    46,447

    Default

    It might have been nice if the client's title block and border was a single attributed block that could be easily erased and replaced. It doesn't appear to be so.

    The client's drawing was done in imperial units and you want to convert everything over to metric units? Have you already worked out the scale factor?

    So everything will be in model space and you will not be using a layout for your new title block and border. Correct?
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

    I'm now a full member of the Society for the Promotion of Mediocrity in CAD. Standards? We don't need no stinkin' standards! Take whatever advice I offer and do the opposite.

  3. #3
    Forum Deity steven-g's Avatar
    Computer Details
    steven-g's Computer Details
    Operating System:
    Win 7
    Discipline
    Construction
    steven-g's Discipline Details
    Occupation
    Draughtsman
    Discipline
    Construction
    Details
    I work in the estimating department of a large building contractor.
    Using
    AutoCAD 2017
    Join Date
    May 2013
    Location
    An Englishman in Belgium
    Posts
    2,055

    Default

    It will depend on what you mean by scaling to fit A2, does it have to be a standard recognisable scale or is scale to fit sufficient, I would personally create a layout with the A2 template and include a viewport, then for each drawing delete the old title block (leaving the old border if it nicely outlines all the drawings), this is easy to do if the layouts are all the same but painful if everything isn't standardised, then import the new layout and zoom extents in the viewport. Then onto the next drawing, it could be a matter of hours or a really painfully slow boring job if all the drawings are laid out differently, and if everything is laid out like the example then a script would be ideal.
    I've just been down graded from 2012LT to full Autocad 2017. I WANT LT BACK

  4. #4
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,815

    Default

    You need to provide a true sample dwg I know about copyright but create a random dwg some plines that represent the bounds of the actual model space dwg but still in feet. The obvious here is to use layouts with the new A2 title block rather than in model. Need a title block that matches the model space objects like Remark the sample its a block at scale of 1 which is not really correct for what you are describing.

    Its possible to find the approx center of the objects and do a metric to feet type scale factor and make a A2.

    The 512 scripting part sounds like the easy bit.

    Ps Steven-g join the dark side and have a go at lisp.
    A man who never made mistakes never made anything

  5. #5
    Forum Deity steven-g's Avatar
    Computer Details
    steven-g's Computer Details
    Operating System:
    Win 7
    Discipline
    Construction
    steven-g's Discipline Details
    Occupation
    Draughtsman
    Discipline
    Construction
    Details
    I work in the estimating department of a large building contractor.
    Using
    AutoCAD 2017
    Join Date
    May 2013
    Location
    An Englishman in Belgium
    Posts
    2,055

    Default

    @ BIGAL
    Never, I'm tinkering with VBA, but this dog is just too old to play with lisp, people like yourself are just too good at it, besides there is that much material available here and other forums that the ability to perform internet searches would find most solutions quicker than trying to learn a new language
    I've just been down graded from 2012LT to full Autocad 2017. I WANT LT BACK

  6. #6
    Forum Newbie
    Using
    AutoCAD 2008
    Join Date
    Dec 2015
    Posts
    7

    Default

    @Remark I'm not sure that the imperial thing is an issue (or is it?). If it's something that can be incorporated easily into a script then I guess it would be a bonus?

    I did consider the layout in paper space but the client cad procedures (LOL) state that the text height must be 2.5mm minimum.

    A few things I have figured out so far which may or may not be useful...

    Scale factor = 33
    Global text style change to 'Standard' (client stipulation)
    Global text height change to 2.5mm (client stipulation)

    Plus a bit of manipulation to get the position right gives me the attached drawing which is very close to what I need (see attached)

    Test_Output.dwg

  7. #7
    Forum Newbie
    Using
    AutoCAD 2008
    Join Date
    Dec 2015
    Posts
    7

    Default

    Is it worthwhile developing a script file or similar to execute the scope detailed above OR should we entertain the manual manipulation route for each individual drawing?

  8. #8
    Forum Deity steven-g's Avatar
    Computer Details
    steven-g's Computer Details
    Operating System:
    Win 7
    Discipline
    Construction
    steven-g's Discipline Details
    Occupation
    Draughtsman
    Discipline
    Construction
    Details
    I work in the estimating department of a large building contractor.
    Using
    AutoCAD 2017
    Join Date
    May 2013
    Location
    An Englishman in Belgium
    Posts
    2,055

    Default

    Text in a layout can be 2.5mm !! Set your paper in the layout as A2. Put the border on the layout. Create a viewport that is as big as possible inside the border. Save it as a template. Then all you need do is open every file insert a new layout from your template. delete or turn off the border in ModelSpace. And in the new layout either zoom extents in the viewport, or if the scale is important then zoom with a scale factor. Save the drawing move onto the next. With a macro that should take only a couple of hours tops and with a script probably only minutes, obviously, that doesn't include doing the preparation and writing/testing of a script or macro. And it also won't make allowances for the odd drawing that for some reason fails the logic of this approach. Only you can judge whether that is going to save you time on this project and how confident you are writing the code, only you have seen how the other drawings may be different.
    I've just been down graded from 2012LT to full Autocad 2017. I WANT LT BACK

  9. #9
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,815

    Default

    Having a look at the dwg this will automate the new title block into a layout using a adjusted fit to the A2 sheet size. I do need some help error trapping the "xref is missing" but it appears to be a logo so should work. Have a look at text size .

    There is no error about if all dwg's are the same so test on a few at a time. I can give you a few hints about writing the script also.

    Code:
    ; Fit model space to a fixed size title block in a layout
    ; By Alan H Aug 2017
    
    (vl-load-com)
    (defun c:ktnl ( / ss lay alllayouts)
    (setvar "ctab" "Model")
    
    (command "erase" (ssget "x" (list (cons 0 "insert")(cons 2 "JE_BORDER")(cons 410 "Model")))  "")
    
    (setq alllayouts (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for lay alllayouts
    (if (= 1 (vla-get-taborder lay))
    (setvar "ctab" (vla-get-name lay))
    )
    )
    
    (command "erase" (ssget "x" (list (cons 0 "Viewport"))) "") 
    
    (setvar "attdia" 0)
    (command "insert" "JE_BORDER" (list 0 0) 1 1 0 "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "")
    
    (command "-layer" "M" "Vport" "")
    (command "mview" (list 7.75 42.0) (list 576.5 405.5))
    (setq obj (vlax-ename->vla-object (entlast)))
    (command "zoom" "E")
    
    (command "mspace")
    (command "zoom" "E")
    (command "zoom" 0.95x)
    (setq sc (vla-get-customscale obj))
    (vla-put-DisplayLocked  obj -1)
    
    (setq ss (ssget "X" (list (cons 0 "Text"))))
    (repeat (setq x (sslength ss))
    (setq tobj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
    (vla-put-height tobj(/ (vla-get-height tobj) sc))
    
    )
    (command "pspace")
    (command "zoom" "E")
    )
    (c:ktnl)
    script if no xrefs
    Code:
    Open dwg1 (load "kntl") close "y")
    Open dwg2 (load "kntl") close "y")
    Open dwg3 (load "kntl") close "y")
    Last edited by BIGAL; 18th Aug 2017 at 02:56 am.
    A man who never made mistakes never made anything

  10. #10
    Forum Newbie
    Using
    AutoCAD 2008
    Join Date
    Dec 2015
    Posts
    7

    Default

    Registered forum members do not see this ad.

    @BIGAL

    Thanks for your response. Apologies, prior to this little adventure I've had very minimal experience of macros/lisp etc and I'm reading 3 separate Autolisp guides concurrently to bring me up to speed.

    I punched in your code to 'Autolisp -> Visual Lisp Editor' and got the following...

    C:KTNL
    ; error: no function definition: VLAX-GET-ACAD-OBJECT
    _$
    _$

Similar Threads

  1. Script with batch
    By Balthor in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 6
    Last Post: 28th Sep 2014, 04:20 am
  2. Run batch with script-pro and keep using your pc
    By CADkitt in forum Tutorials & Tips'n'Tricks
    Replies: 0
    Last Post: 14th Dec 2010, 05:19 pm
  3. help with a batch file and script
    By todouble22 in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 22nd Dec 2009, 05:10 pm
  4. Easiest way to convert a batch of 2007 drawings into 2004 drawings?
    By hhh123kid in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 17th Jun 2008, 04:42 am
  5. running a batch script
    By ariel in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 27th Jul 2006, 05:04 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts