Author Topic: Array of arrays vs Class  (Read 12178 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Array of arrays vs Class
« on: May 16, 2007, 05:42:35 PM »
In my plot routine I use an array of arrays to store all the options for plotting.  I was thinking that I could make a class specific for this instead.  I could set up all the properties I would need, and if I need to add some later, I wouldn't have to rework the code to see the number of items in the array divided by the items per nested array, which I would have to do now.

Is this doable?  Is it a good idea?  Comments/opinions wanted and welcomed.

Thanks in advance.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MickD

  • King Gator
  • Posts: 3638
  • (x-in)->[process]->(y-out) ... simples!
Re: Array of arrays vs Class
« Reply #1 on: May 16, 2007, 06:16:45 PM »
If your array holds arrays of the same data (say an array of strings for options) then yes, wrapping this into a class (or struct even) is a good idea.
This way you can use your class like a 'record' in a db, just create a new one each plot, set it up and add it to the array.
This would make parsing the internal arrays much neater as well.
Is that what you're proposing?
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Array of arrays vs Class
« Reply #2 on: May 16, 2007, 06:20:55 PM »
If your array holds arrays of the same data (say an array of strings for options) then yes, wrapping this into a class (or struct even) is a good idea.
This way you can use your class like a 'record' in a db, just create a new one each plot, set it up and add it to the array.
This would make parsing the internal arrays much neater as well.
Is that what you're proposing?
Yep, that is my line of thinking.  The class/struct will have properties (string, bool, double, int and Acad specific types like StdScaleType and PlotRotation) that will correspond with what the plot engine wants.  I was just reading up on class right now.  I will have a look at struct when I get a chance.  Thanks Mick.

Edit:  This is how I was thinking of setting up my class.
Code: [Select]
public class MyPlotParams {
private string DeviceName;
private string Paper;
private string ctbName;
private bool ScLw;
private double Rot;
private int Cnt;
private Autodesk.AutoCAD.DatabaseServices.StdScaleType ScTyp;
private Autodesk.AutoCAD.DatabaseServices.PlotRotation PltRot;
}
« Last Edit: May 16, 2007, 06:27:43 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MickD

  • King Gator
  • Posts: 3638
  • (x-in)->[process]->(y-out) ... simples!
Re: Array of arrays vs Class
« Reply #3 on: May 16, 2007, 06:42:30 PM »
No prob's, I'm not to sure how structures work in .net but if you could just make your variable public it would save a lot of property get/set code, your could just asign the variables to the plot engine like -

plotEngine.Paper = myPlotParams.Paper;

I think properties are the prefered way to do it though.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

MickD

  • King Gator
  • Posts: 3638
  • (x-in)->[process]->(y-out) ... simples!
Re: Array of arrays vs Class
« Reply #4 on: May 16, 2007, 06:46:16 PM »
or a better example from the array would be -

foreach(plotparam in plotparams)//loop through the plotparams array
{
    plotEngine.Paper = plotparams[ i ].plotparam.Paper;
    plotEngine.DeviceName = plotparams[ i ].plotparam.DeviceName;
    // etc etc
}
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

LE

  • Guest
Re: Array of arrays vs Class
« Reply #5 on: May 16, 2007, 06:51:16 PM »
Tim;

Have a look into this article:

http://www.c-sharpcorner.com/UploadFile/rajeshvs/StructuresInCS11112005234341PM/StructuresInCS.aspx

I have my own examples, but wait for the masters... :)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Array of arrays vs Class
« Reply #6 on: May 16, 2007, 06:58:56 PM »
Since I call my plotting portion like
Code: [Select]
public void MyPlottingPart (
                            string DeviceName,
                            string Paper,
                            string ctbName,
                            StdScaleType ScaleType,
                            bool IsModel,
                            bool ScLws,
                            PlotRotation PltRot,
                            bool LastPlot
                           )
I would pass the properties from the class to it like Mick shows in the first response.
plotEngine.Paper = myPlotParams.Paper;
where I would make a new class object per file to plot.  I have constructed the constructor to MyPlotParms like
Code: [Select]
public MyPlotParams(){}
public MyPlotParams(string DwgPath, string DeviceName, string Paper, string ctbName, bool ScLw, double Rot, int Cnt, Autodesk.AutoCAD.DatabaseServices.StdScaleType ScTyp, Autodesk.AutoCAD.DatabaseServices.PlotRotation PltRot) {
this.DwgPath = DwgPath;
this.DeviceName = DeviceName;
this.Paper = Paper;
this.ctbName = ctbName;
this.ScLw = ScLw;
this.Rot = Rot;
this.Cnt = Cnt;
this.ScTyp = ScTyp;
this.PltRot = PltRot;
}
This is the way I'm heading right now.  If it seems wrong please let me know.

Tim;

Have a look into this article:

http://www.c-sharpcorner.com/UploadFile/rajeshvs/StructuresInCS11112005234341PM/StructuresInCS.aspx

I have my own examples, but wait for the masters... :)
Luis thanks for the link.  :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Array of arrays vs Class
« Reply #7 on: May 16, 2007, 07:06:52 PM »
Tim;

I know that later, the ones that really know, will guide better, but on the mean time, let me post a little simple class I wrote for one of my routines, it might help, I do not know... :)

Code: [Select]
    public partial class Door : DoorsAndWindowsForm
    {
        // Declarations
        private ObjectId m_blockid       = new ObjectId();
        private const Int32 m_vertices   = 4;
        private String m_doorName        = "";
        private Double m_doorThick       = 1.75; //1-3/4"
        private Double m_doorWidth       = 0.0;
        private Double m_wallThick       = 0.0;
        private Double m_dirRight        = 0.0;
        private Double m_dirUp           = 0.0;
        private Double m_dirLeft         = 0.0;
        private Double m_swingStartAngle = 0.0;
        private Double m_swingEndAngle   = 0.0;

        public enum Names
        {
            dr90,
            dr45,
            dr30,
            dr15,
            dr180,
            drPair90,
            drPair90egress,
            drSliding,
            drPocket,
            drFolding,
            Rolling
        };

        // Default Constructor
        public Door()
        {
        }

        // Alternate constructor
        public Door(Double doorWidth, Double wallThick, int drValue)
        {
            drWidth = doorWidth;
            getDoorName(drValue);

            Database db = HostApplicationServices.WorkingDatabase;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                ...

                Entity[] ent = new Entity[entities.Count];
                entities.CopyTo(ent, 0);
                ObjectId blockid = makeBlock("*U", ent);

                DoorId = blockid;

                // remove originals
                en1.Erase(true);
                en2.Erase(true);
                en3.Erase(true);
                en4.Erase(true);

                tr.Commit();
            }
        }

        // Properties
        public Double SwingStartAngle
        {
            get
            {
                return m_swingStartAngle;
            }
            set
            {
                m_swingStartAngle = value;
            }
        }

        public Double SwingEndAngle
        {
            get
            {
                return m_swingEndAngle;
            }
            set
            {
                m_swingEndAngle = value;
            }
        }

        public ObjectId DoorId
        {
            get
            {
                return m_blockid;
            }
            set
            {
                m_blockid = value;
            }
        }

        public Double DirRight
        {
            get
            {
                return m_dirRight;
            }
            set
            {
                m_dirRight = value;
            }
        }

        public Double DirUp
        {
            get
            {
                return m_dirUp;
            }
            set
            {
                m_dirUp = value;
            }
        }

        public Double DirLeft
        {
            get
            {
                return m_dirLeft;
            }
            set
            {
                m_dirLeft = value;
            }
        }

        public Double Thick
        {
            get
            {
                return m_doorThick;
            }
            set
            {
                m_doorThick = value;
            }
        }

        public Double drWidth
        {
            get
            {
                return m_doorWidth;
            }
            set
            {
                 m_doorWidth = value;
            }
        }

        public Double WallThick
        {
            get
            {
                return m_wallThick;
            }
            set
            {   
                m_wallThick = value;
            }
        }

        public String drName
        {
            get
            {
                return m_doorName;
            }
            set
            {
                m_doorName = value;
            }
        }

        public String getDoorName(int valor)
        {
            string block_dwg = "90 degrees swing"; //default
            switch (valor)
            {
                case 0:
                    SwingStartAngle = 0.0;
                    SwingEndAngle = c90Degrees;
                    DirRight = 0.0;
                    DirUp = c90Degrees;
                    DirLeft = Math.PI;
                    drName = "90 degrees swing";
                    block_dwg = "90 degrees swing";
                    break;
                case 1:
                    SwingStartAngle = 0.0;
                    SwingEndAngle = 0.785398;
                    DirRight = c315Degrees;
                    DirUp = c45Degrees;
                    DirLeft = c135Degrees;
                    drName = "45 degrees swing";
                    block_dwg = "45 degrees swing";
                    break;
                case 2:
                    SwingStartAngle = 0.0;
                    SwingEndAngle = 0.523599;
                    DirRight = 5.23599;
                    DirUp = 0.523599;
                    DirLeft = 2.0944;
                    drName = "30 degrees swing";
                    block_dwg = "30 degrees swing";
                    break;
                case 3:
                    SwingStartAngle = 0.0;
                    SwingEndAngle = 0.261799;
                    DirRight = 4.97419;
                    DirUp = 0.2618;
                    DirLeft = 1.8326;
                    drName = "15 degrees swing";
                    block_dwg = "15 degrees swing";
                    break;
                case 4:
                    SwingStartAngle = 0.0;
                    SwingEndAngle = Math.PI;
                    DirRight = c90Degrees;
                    DirUp = Math.PI;
                    DirLeft = c270Degrees;
                    drName = "180 degrees swing";
                    block_dwg = "180 degrees swing";
                    break;
                case 5: // ignore this door - remove from here
                    block_dwg = "Pair 90 degrees swing";
                    break;
                case 6: // ignore this door - remove from here
                    block_dwg = "Pair 90 degrees double egress";
                    break;
                case 7:
                    block_dwg = "Sliding";
                    break;
                case 8:
                    block_dwg = "Pocket";
                    break;
                case 9:
                    block_dwg = "Folding";
                    break;
                case 10:
                    block_dwg = "Rolling";
                    break;
            }
            return block_dwg;
        }
               
    }//end of Door class

Then, when I need to change/update one of the doors I just read all the data in the dictionaries and call it like:

Code: [Select]
Door door = new Door(dw, wwidth, doorNamesIndex);
Point2d pgeo = new Point2d(x, y);

// save values to door!!!
door.drName = dname;
door.WallThick = wwidth;
 door.drWidth = dw;

Super Mickey Mouse.... I know..
« Last Edit: May 17, 2007, 10:10:39 AM by LE »

MickD

  • King Gator
  • Posts: 3638
  • (x-in)->[process]->(y-out) ... simples!
Re: Array of arrays vs Class
« Reply #8 on: May 16, 2007, 07:13:56 PM »
That link has all you need to know, if you don't need member methods/functions there's no need to create a class. You create a struct the same as a class but as the member var's are public you just assign straight to them as you would any ather variable except you use the struct's instance name in front like -

MyStruct s = new MyStruct();
s.var1 = somevar;
s.var2 = another var
etc....
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Array of arrays vs Class
« Reply #9 on: May 16, 2007, 07:23:19 PM »
Tim;

I know that later, the ones that really know, will guide better, but on the mean time, let me post a little simple class I wrote for one of my routines, it might help, I do not know... :)
<snip>
Thanks Luis.  This will take me some time to digest.

That link has all you need to know, if you don't need member methods/functions there's no need to create a class. You create a struct the same as a class but as the member var's are public you just assign straight to them as you would any ather variable except you use the struct's instance name in front like -

MyStruct s = new MyStruct();
s.var1 = somevar;
s.var2 = another var
etc....
This what I was thinking out of reading that article.  A struct sounds like it may be better suited for what I'm doing right now.

Thanks you two.  I'm off to play now, and tomorrow since today is almost done, and I have to take my car to the shop right after work.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8735
  • AKA Daniel
Re: Array of arrays vs Class
« Reply #10 on: May 16, 2007, 11:00:42 PM »
In my plot routine I use an array of arrays to store all the options for plotting.  I was thinking that I could make a class specific for this instead.  I could set up all the properties I would need, and if I need to add some later, I wouldn't have to rework the code to see the number of items in the array divided by the items per nested array, which I would have to do now.

Is this doable?  Is it a good idea?  Comments/opinions wanted and welcomed.

Thanks in advance.

Hi Tim,

The Framework Design Guidelines say that the maximum size of a struct should be around 16 bytes,
they should be used for making value types. In your case you should consider using a class along with something
from System.Collections.Generic.. For example List<T>

Dan

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Array of arrays vs Class
« Reply #11 on: May 16, 2007, 11:20:18 PM »
In my plot routine I use an array of arrays to store all the options for plotting.  I was thinking that I could make a class specific for this instead.  I could set up all the properties I would need, and if I need to add some later, I wouldn't have to rework the code to see the number of items in the array divided by the items per nested array, which I would have to do now.

Is this doable?  Is it a good idea?  Comments/opinions wanted and welcomed.

Thanks in advance.

Hi Tim,

The Framework Design Guidelines say that the maximum size of a struct should be around 16 bytes,
they should be used for making value types. In your case you should consider using a class along with something
from System.Collections.Generic.. For example List<T>

Dan

Dan,

  Does .Net 1.1 support 'Generic's?  I didn't think it did.  I will do some research on this tomorrow.  Thanks for the idea.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8735
  • AKA Daniel
Re: Array of arrays vs Class
« Reply #12 on: May 16, 2007, 11:26:50 PM »
  Does .Net 1.1 support 'Generic's?  I didn't think it did.  I will do some research on this tomorrow.  Thanks for the idea.

Nope, May I ask why your not using a newer framework?

MickD

  • King Gator
  • Posts: 3638
  • (x-in)->[process]->(y-out) ... simples!
Re: Array of arrays vs Class
« Reply #13 on: May 16, 2007, 11:27:58 PM »
...

The Framework Design Guidelines say that the maximum size of a struct should be around 16 bytes,
...

Is that for real?! I noticed that struct's derive from value type (therefore are by inheritance) and I also read that value types are 'recommended' to be 16bytes, does that apply for subclasses like struct's, it just doesn't sound right.
It sucks if it is right though, a struct is a perfect solution for something that just needs to hold data in bundles like in Tim's situation.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8735
  • AKA Daniel
Re: Array of arrays vs Class
« Reply #14 on: May 17, 2007, 12:28:37 AM »
Here is one link http://msdn2.microsoft.com/en-us/library/y23b5415(VS.71).aspx

From what I gather, it’s just a matter of efficiency. I read a great article (I need to find the link) which explained the impact of placing large objects on the managed stack. Interesting stuff.

MickD

  • King Gator
  • Posts: 3638
  • (x-in)->[process]->(y-out) ... simples!
Re: Array of arrays vs Class
« Reply #15 on: May 17, 2007, 12:35:04 AM »
Ahh, the stack size eh!, thanks Dan...still sucks though :laugh:
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

TonyT

  • Guest
Re: Array of arrays vs Class
« Reply #16 on: May 17, 2007, 02:02:00 AM »
Hi Tim. Don't use a struct for something like that.

I don't know if anyone mentioned it, but a struct is a value type,
which when passed to a function as an argument, is passed by
value (e.g., a copy of the struct is created and passed).

When you pass an instance of a class to a function, only a
reference to the class is passed, and there is no copy made.

Tim;

I know that later, the ones that really know, will guide better, but on the mean time, let me post a little simple class I wrote for one of my routines, it might help, I do not know... :)
<snip>
Thanks Luis.  This will take me some time to digest.

That link has all you need to know, if you don't need member methods/functions there's no need to create a class. You create a struct the same as a class but as the member var's are public you just assign straight to them as you would any ather variable except you use the struct's instance name in front like -

MyStruct s = new MyStruct();
s.var1 = somevar;
s.var2 = another var
etc....
This what I was thinking out of reading that article.  A struct sounds like it may be better suited for what I'm doing right now.

Thanks you two.  I'm off to play now, and tomorrow since today is almost done, and I have to take my car to the shop right after work.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Array of arrays vs Class
« Reply #17 on: May 17, 2007, 10:38:29 AM »
  Does .Net 1.1 support 'Generic's?  I didn't think it did.  I will do some research on this tomorrow.  Thanks for the idea.

Nope, May I ask why your not using a newer framework?
I'm still on '06, and they told me not to go to .Net 2.0.  I have the newer version on my system, but just not using it right now.

Quote from: TonyT
Hi Tim. Don't use a struct for something like that.

I don't know if anyone mentioned it, but a struct is a value type,
which when passed to a function as an argument, is passed by
value (e.g., a copy of the struct is created and passed).

When you pass an instance of a class to a function, only a
reference to the class is passed, and there is no copy made.
Thanks Tony.

So I guess the way to go is a class per what everyone is saying here.  I have meetings this morning, so I will have to look into this in the afternoon.

Thanks once again all.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Array of arrays vs Class
« Reply #18 on: May 17, 2007, 06:35:29 PM »
Class was the way to go.  I made a class, then assigned it to the 'tag' of each item in the listview.  Then when the plot button is pressed I fill a global object array with the tags from the listview.  Works nice.
Class
Code: [Select]
public class MyPlotParams {
private string DwgPath;
private string DeviceName;
private string PaperSize;
private string ctbName;
private bool ScLw;
private int Cnt;
private Autodesk.AutoCAD.DatabaseServices.StdScaleType ScTyp;
private Autodesk.AutoCAD.DatabaseServices.PlotRotation PltRot;

public MyPlotParams(){}
public MyPlotParams(string DwgPath, string DeviceName, string PaperSize, string ctbName, bool ScLw, int Cnt, Autodesk.AutoCAD.DatabaseServices.StdScaleType ScTyp, Autodesk.AutoCAD.DatabaseServices.PlotRotation PltRot) {
this.DwgPath = DwgPath;
this.DeviceName = DeviceName;
this.Paper = PaperSize;
this.ctbName = ctbName;
this.ScLw = ScLw;
this.Cnt = Cnt;
this.ScTyp = ScTyp;
this.PltRot = PltRot;
}

public string DrawingPath {
get {return DwgPath;}
set {DwgPath = value;}
}

public string Device {
get {return DeviceName;}
set {DeviceName = value;}
}

public string Paper {
get {return PaperSize;}
set {PaperSize = value;}
}

public string ctbFile {
get {return ctbName;}
set {ctbName = value;}
}

public bool ScaleLineweight {
get {return ScLw;}
set {ScLw = value;}
}

public int Amount {
get {return Cnt;}
set {Cnt = value;}
}

public Autodesk.AutoCAD.DatabaseServices.StdScaleType AcScaleType {
get {return ScTyp;}
set {ScTyp = value;}
}

public Autodesk.AutoCAD.DatabaseServices.PlotRotation AcPlotRotation {
get {return PltRot;}
set {PltRot = value;}
}
}
Then when it comes to plotting the drawings.
Code: [Select]
if (DiaRslt == DialogResult.OK) {
bool IsModel;
Document tempDoc = null;
DocumentCollection DocCol = AcadApp.DocumentManager;
foreach (MyPlotParams mpp in PlotObjectsArray) {
if (mpp != null) {
try {
tempDoc = DocCol.Open(mpp.DrawingPath, true);
using (DocumentLock DocLock = tempDoc.LockDocument()) {
if (string.Compare("Model", LayoutManager.Current.CurrentLayout) == 0) {
IsModel = true;
}
else IsModel = false;
MyPlottingPart(mpp.Device,
               mpp.Paper,
               mpp.Amount,
               mpp.ctbFile,
               mpp.AcScaleType,
               IsModel,
               mpp.ScaleLineweight,
               mpp.AcPlotRotation,
               true
              );
}
}
catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message, "Drawing error (AutoCAD).");
}
catch (System.Exception ex){
MessageBox.Show(ex.Message, "Drawing error (System).");
}
finally {
if (tempDoc != null) tempDoc.CloseAndDiscard();
}
}
}
}

Thanks again for all the help.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MickD

  • King Gator
  • Posts: 3638
  • (x-in)->[process]->(y-out) ... simples!
Re: Array of arrays vs Class
« Reply #19 on: May 17, 2007, 06:58:31 PM »
Nice work Tim, sorry to lead you astray with the struct's (that's how I'd do it in C), we all learned something out of it though  :roll:
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Array of arrays vs Class
« Reply #20 on: May 17, 2007, 07:05:28 PM »
Nice work Tim, sorry to lead you astray with the struct's (that's how I'd do it in C), we all learned something out of it though  :roll:
True.  If I go down one path and find it's not the right one, I know I at the minimum learned something.  I appreciate your help Mick.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

TonyT

  • Guest
Re: Array of arrays vs Class
« Reply #21 on: May 18, 2007, 12:08:54 AM »
Hi Tim.

On thing I noticed about your code is that it will try to close a document
that may not have been opened, because the finally{} block executes,
regardless of whether the document was opened or not.

You might want to consider rearranging your code to ensure that it
doesn't try to close a document that may not have been opened.

The general pattern might be like this:

Code: [Select]

    try
    {
         // open document here
        if( <document was opened successfully> )
        {
            try
            {
                  // work with opened document here
            }
            catch (Exceptions that might occur while working with open document)
            {
            }
            finally
            {
                 // close the opened document
            }
        }
        catch( Exception that might occur attempting to open the document )
        {
        }
   }       // outer try


One other thing is that you can unclutter your code logic by passing
the MyPlotParams instance to MyPlottingPart() and use its properties
directly from within that function.
     
Class was the way to go.  I made a class, then assigned it to the 'tag' of each item in the listview.  Then when the plot button is pressed I fill a global object array with the tags from the listview.  Works nice.
Class
Code: [Select]
public class MyPlotParams {
private string DwgPath;
private string DeviceName;
private string PaperSize;
private string ctbName;
private bool ScLw;
private int Cnt;
private Autodesk.AutoCAD.DatabaseServices.StdScaleType ScTyp;
private Autodesk.AutoCAD.DatabaseServices.PlotRotation PltRot;

public MyPlotParams(){}
public MyPlotParams(string DwgPath, string DeviceName, string PaperSize, string ctbName, bool ScLw, int Cnt, Autodesk.AutoCAD.DatabaseServices.StdScaleType ScTyp, Autodesk.AutoCAD.DatabaseServices.PlotRotation PltRot) {
this.DwgPath = DwgPath;
this.DeviceName = DeviceName;
this.Paper = PaperSize;
this.ctbName = ctbName;
this.ScLw = ScLw;
this.Cnt = Cnt;
this.ScTyp = ScTyp;
this.PltRot = PltRot;
}

public string DrawingPath {
get {return DwgPath;}
set {DwgPath = value;}
}

public string Device {
get {return DeviceName;}
set {DeviceName = value;}
}

public string Paper {
get {return PaperSize;}
set {PaperSize = value;}
}

public string ctbFile {
get {return ctbName;}
set {ctbName = value;}
}

public bool ScaleLineweight {
get {return ScLw;}
set {ScLw = value;}
}

public int Amount {
get {return Cnt;}
set {Cnt = value;}
}

public Autodesk.AutoCAD.DatabaseServices.StdScaleType AcScaleType {
get {return ScTyp;}
set {ScTyp = value;}
}

public Autodesk.AutoCAD.DatabaseServices.PlotRotation AcPlotRotation {
get {return PltRot;}
set {PltRot = value;}
}
}
Then when it comes to plotting the drawings.
Code: [Select]
if (DiaRslt == DialogResult.OK) {
bool IsModel;
Document tempDoc = null;
DocumentCollection DocCol = AcadApp.DocumentManager;
foreach (MyPlotParams mpp in PlotObjectsArray) {
if (mpp != null) {
try {
tempDoc = DocCol.Open(mpp.DrawingPath, true);
using (DocumentLock DocLock = tempDoc.LockDocument()) {
if (string.Compare("Model", LayoutManager.Current.CurrentLayout) == 0) {
IsModel = true;
}
else IsModel = false;
MyPlottingPart(mpp.Device,
               mpp.Paper,
               mpp.Amount,
               mpp.ctbFile,
               mpp.AcScaleType,
               IsModel,
               mpp.ScaleLineweight,
               mpp.AcPlotRotation,
               true
              );
}
}
catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message, "Drawing error (AutoCAD).");
}
catch (System.Exception ex){
MessageBox.Show(ex.Message, "Drawing error (System).");
}
finally {
if (tempDoc != null) tempDoc.CloseAndDiscard();
}
}
}
}

Thanks again for all the help.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Array of arrays vs Class
« Reply #22 on: May 21, 2007, 11:20:40 AM »
Thanks for the points Tony.  I like them, and will update my code when I get a chance to.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Atook

  • Swamp Rat
  • Posts: 1030
  • AKA Tim
Re: Array of arrays vs Class
« Reply #23 on: May 21, 2007, 02:24:35 PM »
Silly question, I'm not even coding in .NET yet, but isn't an array of arrays the same as a multi-dimensional array?

IE: Dim 2DArray (0 to 5, 0 to 10) as double

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Array of arrays vs Class
« Reply #24 on: May 21, 2007, 02:31:16 PM »
Silly question, I'm not even coding in .NET yet, but isn't an array of arrays the same as a multi-dimensional array?

IE: Dim 2DArray (0 to 5, 0 to 10) as double
Yea (I think so).  Array of arrays just came to mind while typing.  :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

sinc

  • Guest
Re: Array of arrays vs Class
« Reply #25 on: May 21, 2007, 08:49:45 PM »
Doesn't a two-dimensional array have to be "rectangular"?  In other words, array[5][10] has five rows, each of which has 10 columns, but an array of arrays might imply that each row has a different number of columns?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Array of arrays vs Class
« Reply #26 on: May 21, 2007, 11:17:51 PM »
............. imply that each row has a different number of columns?

In that case it becomes a jagged array, yes ?

http://msdn2.microsoft.com/en-us/library/2s05feca(VS.80).aspx
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

sinc

  • Guest
Re: Array of arrays vs Class
« Reply #27 on: May 22, 2007, 12:01:28 AM »
Yeah, like that.