+ Reply to Thread
Results 1 to 17 of 17

Manipulating Shapes

  1. #1
    Registered User
    Join Date
    03-11-2010
    Location
    SINGAPORE
    MS-Off Ver
    Excel 2007
    Posts
    12

    Lightbulb Manipulating Shapes

    Hi folks,
    i have been thinking for several days how to implement a VBA program that can generate shapes from data entered on a worsksheet.
    Basically, it is to analyse the filling of cable trays with cables.
    The user will enter cable diameters, and the tray width ( e.g 300mm).
    Depending on the diameter the program will generate circles with according diameter on a tray .
    All should be to scale.
    Circles has to be side by side ( which to me is the most difficult part), and can be on 1,2 or 3 layers ( slectable by the user on a form).
    I am at the evaluation stage, and thinking if it will not be easier using VISIO, but i never tried vba on visio, or , from an excel WS, generate a script that can be exported in Autocad ???
    I am working on the excel solution only, but any ideas are welcome. I just started in VBA with shapes, so not sure if it is the correct way to go for my project.
    Thanks for your feedback.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Manipulating Shapes

    I would suggest that if you have access to AutoCAD, tackle the problem from there.

    AutoCAD can scale blocks, position them, and put them on layers of your choice. That's what it's for.
    AutoCAD uses VBa and can be programmed to read an Excel file but it is easier to read a CSV.

    Shapes in Excel are not, in my opinion, the easiest thing in the world to control so if you don't need the Excel Sheet to show graphic, go the AutoCAD route.

    You can always use the AutoCAD result for a display in Excel.

    Just an opinion.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Manipulating Shapes

    I didn't know AutoCAD supported VBA ... huh.

    One advantage of using Visio is that it has a macro recorder. I've never automated Visio (and never used AutoCAD), and so can't make an informed recommendation, but I suspect Visio would be easier if the problem is more drawing-oriented, and AutoCAD if the problem is more CAD-oriented.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Manipulating Shapes

    As of Release 14 AutoCAD supports use of VBA and there are code snippets available via a web search as well as tutorials. However, though VBA is supported, they are moving toward support of .NET.

    I agree with Marcol - skip Excel and work directly within AutoCAD.

    Strictly speaking, Visio doesn't support layers like CAD, but (sort of) simulates layers by allowing a background sheet for common page elements and each sheet is, like Excel, independent from other sheets.

    AutoCAD VBA Support
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Manipulating Shapes

    Visio doesn't support layers like CAD
    Visio does support named layers, and independent control (e.g., visibility) for each.

  6. #6
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Manipulating Shapes

    Visio does support named layers, and independent control (e.g., visibility) for each.
    I may have misspoken on that point, but the PC I'm on now doesn't have Visio and I don't typically need layers. Does the layer features exist in pre-2007 versions?

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Manipulating Shapes

    I only have 2007 now, P, but recollect it existed at least back to 2002.

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Manipulating Shapes

    AutoCAD has supported VBa since R14 (1997) prior to that the language was AutoLisp & with great difficulty DIESEL.

    It is not unlike VBa in MSoffice but with obviously many specialised commands. It has an annoying ability to use commands very similar to office in slightly different ways and can cause great frustration when working on the two systems at the same time.

    AutoCAD is possibly the most versitle drawing system commonly available. The ability to programme it with VBa means it is extremely flexible.

    The scaling aspect is not easily done in Visio nor is the drawing when compared to AutoCAD.
    Layers are not inherent in Visio although they can be simulated with VBa

    I do all of my more complicated drawings for Visio in AutoCAD then import them and tweak to suit.

    If it was me, I'd go the AutoCAD route.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Manipulating Shapes

    Layers are not inherent in Visio
    Please Login or Register  to view this content.

  10. #10
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Manipulating Shapes

    Sorry shg I was comparing Visio to AutoCAD which has infinitely more control

    I have probably missed the potential of Visio layers because of this.
    Last edited by Marcol; 03-20-2010 at 01:15 PM. Reason: spelling

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Manipulating Shapes

    I was comparing Visio to AutoCAD which has infinitely more control
    I don't doubt that. Visio is an office (small o) drawing program. I know some AutoCAD wizards, and they do amazing stuff in 3D.

  12. #12
    Registered User
    Join Date
    03-11-2010
    Location
    SINGAPORE
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Manipulating Shapes

    Thanks All for your advices.
    However i may miss explained the "layers " i am talking about.
    I mean layers on the Tray itself, so all shapes will be on the same plane area. I should have said "rows" instead.
    As for my project i will limit the rows to 3 maximum per tray.
    AutoCAD is surely the best way to go when you are comfortable with scripts. I also not sure how to arrange the circles side by side, of different diameter .
    Another pb i think, is that it requires to have two programs to make it work,not very " professionnal", but if there is no other way, i will work on it.
    Thanks again for your critcial advices.

  13. #13
    Forum Contributor
    Join Date
    04-03-2007
    Location
    Auckland, New Zealand
    MS-Off Ver
    2007
    Posts
    137

    Re: Manipulating Shapes

    Hi,
    Not sure if this will help your cause.. but the attached is something I use to draw proportinate venn diagrams.
    You may be able to pull apart and tweak for your needs.
    It draws circles and positions them correctly.
    Attached Files Attached Files

  14. #14
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Manipulating Shapes

    Hi Breizh29
    I use Drawing Exchange Format (DXF) file then open and reference the file in AutoCad .
    with dxf you can set the layers and shapes lines text ect....
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  15. #15
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Manipulating Shapes

    Hi Breizh29

    This might be worth a try.

    The resulting drawing is very basic but it should be enough to demonstrate the principle.

    1/. Open AutoCAD

    2/. Press Alt + f11 to open the visual basic editor
    Or Tools > Macros > Visual Basic Editor

    3/. In the Editor
    Insert > Module

    4/. Copy and paste all of the code below into this empty module.

    5/- Change this Sub to suit the full path name to where you have stored the Sample Excel File attached.
    Please Login or Register  to view this content.
    5/. Close the editor.

    6/. In AutoCAD
    Press Alt + f8 to open the Macro Dialogue Box
    Or Tools > Macro > Macros........
    There will only be one Macro. Select it and Press Run

    This routine will open Excel and open file CableTrays.XLS,
    Loop through the table, draw each tray and fill it with cables to capacity of the tray.
    The number of rows, number of cables per row/layer, and the total number of cables are entered in Excel

    If Excel was open when the macro was run it will leave Excel open.
    if not it will close the Application.

    The cables are *stacked" not "nested" and are allowed to protrude above the tray lip by up to 50% of the cable diameter.

    The code is a "mixture" of the two VBa types.


    Please Login or Register  to view this content.

    I have only tried this in AutoCAD 2005 and Excel 2003, but it should be okay in other versions.

    Hope this might be of some help.
    Attached Files Attached Files
    Last edited by Marcol; 03-21-2010 at 04:16 PM. Reason: Clarification of description

  16. #16
    Registered User
    Join Date
    03-11-2010
    Location
    SINGAPORE
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Manipulating Shapes

    Thanks very much Marcol for your work.
    I were not expecting so much !!!
    I will give a try this evening, and surely it will inspire me to go further in my project.
    Thanks again.

  17. #17
    Registered User
    Join Date
    03-11-2010
    Location
    SINGAPORE
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Manipulating Shapes

    Thanks JBentley,
    your code gives me plenty idea how to implement this shape draw automation.
    I am working in fact on both solution ( Autocad + Excel AND Excel with Autoshape).
    I will try to post my results within the few days, if i reach the end !

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1