Author Topic: Using Excel to control AutoCAD  (Read 18839 times)

0 Members and 1 Guest are viewing this topic.

Gasty

  • Newt
  • Posts: 90
Re: Using Excel to control AutoCAD
« Reply #30 on: April 24, 2013, 02:46:12 PM »
Hi,

May I'm missing something, but another alternative could be create a DXF file "by hand", starting with a "smart" DXF template (predefined blocks, styles, layers,etc) , it's not  that complicate to do so, and it doesn't requires any other software, only AutoCAD for the template creation and testing. However this solution goes from very complicated to impossible if you need solids or surfaces to represent the final result.

Gaston Nunez




WILL HATCH

  • Bull Frog
  • Posts: 450
Re: Using Excel to control AutoCAD
« Reply #31 on: April 24, 2013, 06:39:47 PM »
As far as I understood the OP wants to see changes in real time

GegH1

  • Guest
Re: Using Excel to control AutoCAD
« Reply #32 on: April 24, 2013, 07:12:06 PM »
That's right, he would like changes in real time.
It also sounds like the DevDept product would meet all his criteria except cost and time, which is quite a large part of the criteria. It is sounding a little like the cost and time criteria are a little unrealistic for any of the options.
The option to draw in excel is probablt the most realistic but i'm not sure the result will be 'fine' enough.
I have a meeting with the client tomorrow to discuss options and will come back here to let you know what happens.

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: Using Excel to control AutoCAD
« Reply #33 on: April 25, 2013, 12:13:55 PM »
The question in my mind now, is why not just combine a few of the suggestions here... Using WPF to draw the real time visual isn't too hard, creating a DXF file which could be imported into AutoCAD isn't too hard either.  Since you're only drawing a simple shed you will only need to worry about simple faces, unless there is a greater level of detail required in the DWG we aren't aware of.

GegH1

  • Guest
Re: Using Excel to control AutoCAD
« Reply #34 on: April 25, 2013, 04:51:28 PM »
4 walls, pitched roof, doors and windows.

Size and number of openings as well as size of shed and pitch of roof are variable.

TheMaster

  • Guest
Re: Using Excel to control AutoCAD
« Reply #35 on: April 25, 2013, 08:15:15 PM »
That's right, he would like changes in real time.
It also sounds like the DevDept product would meet all his criteria except cost and time, which is quite a large part of the criteria. It is sounding a little like the cost and time criteria are a little unrealistic for any of the options.
The option to draw in excel is probablt the most realistic but i'm not sure the result will be 'fine' enough.
I have a meeting with the client tomorrow to discuss options and will come back here to let you know what happens.

Here is something I found interesting, built with WPF graphics and Silverlight:

   http://numeracyworks.com/Site/Home.html

Using this free library:

  http://livegeometry.codeplex.com/

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: Using Excel to control AutoCAD
« Reply #36 on: April 25, 2013, 08:33:40 PM »
Thanks Tony, very interesting

GegH1

  • Guest
Re: Using Excel to control AutoCAD
« Reply #37 on: April 25, 2013, 10:21:24 PM »
The websites keep crashing on me, ie9, win 7 64bit.

AKS

  • Guest
Re: Using Excel to control AutoCAD
« Reply #38 on: May 12, 2013, 11:40:05 PM »
Have your Excel code write out text files describing the shed. Have a Processing (www.processing.org) application you write use those files to constantly regenerate the shed image. One of the text files could contain information about how the image is to be viewed if you did not want to add view controls to the Processing application. If the shed parts are always the same, for example it always has something that would be the roof, then there could be simple controls at the Processing side to perform visibility operations on the parts.

fixo

  • Guest
Re: Using Excel to control AutoCAD
« Reply #39 on: May 13, 2013, 05:10:31 PM »
That's interesting Fixo, i imagine it wouldn't take a lot to adapt this to manipulate a dynamic block based on numbers in the excel sheet?
Do you think it could do this dynamically as you move from Cell to cell?
Sorry for the belating, here is code snip from my test form
You can only select mating cells in a column and / or row this way
Code: [Select]
       //
        //                     * clean up *
        //
        private static void releaseObject(object obj)
        {
            try
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
                obj = null;
            }
            catch (System.Exception ex)
            {
                obj = null;
                MessageBox.Show("An error occurred while releasing memory of the object" + ex.ToString());
            }
            finally
            {
                if (obj != null)
                {
                    int pos = GC.GetGeneration(obj);
                    GC.Collect(pos);
                }
                else { GC.Collect(); }
                GC.WaitForPendingFinalizers();
            }
        }

       
        //using Excel = Microsoft.Office.Interop.Excel;
       // defined on Form scope
        //string strFileName = "C:\\Test\\Cars.xls";
        //Excel.Application xlApp = default(Excel.Application);
        private void btnRef_Click(object sender, EventArgs e)
        {
            string rangeAddress = "";
            StringBuilder sb = new StringBuilder();
            xlApp = new Excel.ApplicationClass();
            Excel.Workbook xlWorkBook = default(Excel.Workbook);
            Excel.Worksheet xlWorkSheet = default(Excel.Worksheet);
            Excel.Range xlRange = default(Excel.Range);
            xlApp.Visible = true;
            object misValue = System.Reflection.Missing.Value;
            xlWorkBook = xlApp.Workbooks.Open(strFileName, misValue, misValue, misValue
                                              , misValue, misValue, misValue, misValue
                                             , misValue, misValue, misValue, misValue
                                            , misValue, misValue, misValue);
           
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
           
            xlWorkSheet = (Excel.Worksheet)xlApp.ActiveSheet;
           xlApp.ScreenUpdating = true;
            xlApp.DisplayAlerts = false;
            xlApp.Interactive = false;
    Excel.Range range = null;
    try
    {
        range = (Excel.Range)xlApp.Application.InputBox("Select cell range", Type.Missing, Type.Missing, Type.Missing,
                                Type.Missing, Type.Missing, Type.Missing, 8) as Excel.Range;

        xlApp.DisplayAlerts = true;
        if (range != null)
            rangeAddress = ((Excel.Range)range).AddressLocal;
        object data = ((Excel.Range)range).Value;
        object[,] varArray = (object[,])data;
        ((Excel._Workbook)xlWorkBook).Close(false);
        xlApp.Quit();
        foreach (object item in varArray)
            sb.AppendLine(item.ToString());
       
                     
    }
    catch
    {
        xlApp.Quit();
        releaseObject(xlRange);
        releaseObject(xlWorkSheet);
        releaseObject(xlWorkBook);
        releaseObject(xlApp);
    }
    finally
    {

        if (xlApp != null) System.Runtime.InteropServices.Marshal.FinalReleaseComObject(xlApp);
        xlApp = null;
        MessageBox.Show(sb.ToString());
       
    }
    }
You can change this to your suit