Author Topic: NET Party with Bricscad.  (Read 17991 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
NET Party with Bricscad.
« on: February 26, 2008, 12:53:34 AM »
Off on one of my tangents again, I have stuck all my .NET SDS wrappers into a DRX module that can be loaded into the latest version of Bricscad. Most of it doesn’t work yet. I have not wrapped any of the DRX classes yet. None of the GetXXX() methods work with forms. You can however stick the attached module in your Bricscad support folder and load it via the appload command, and then … you can netload your .NET assemblies. You can add references to the Bricscad COM objects if you want to party on that API. I’ll post the source if someone wants to have a laugh, although you can see it via reflector.

..

latest builds are here

NOTE: this is old stuff please go here http://www.theswamp.org/index.php?topic=29100.0
« Last Edit: January 13, 2010, 07:14:46 AM by Daniel »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #1 on: February 26, 2008, 01:02:06 AM »
Oh yeah, set copy local to false, when you reference this DLL

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #2 on: March 05, 2008, 11:48:53 PM »
w00t

Code: [Select]
   [CommandMethodAttribute("AddLayer")]
    public static void test4()
    {
      using (BriApplication BriApp = new BriApplication())
      {
        try
        {
          AcadApplication app = BriApp.Application;
          AcadDocument Doc = app.ActiveDocument;
          AcadDatabase Db = Doc.Database;
          AcadLayers layers = Db.Layers;

          AcadLayer layer = layers.Add("New Layer");
          layer.color = AcColor.acBlue;
          layer.Description = "Cool New Layer";
          layer.Lineweight = ACAD_LWEIGHT.acLnWt009;

          DRXNET.SDS.SDSMethods.Alert
            ("Added layer: " + layer.Name + "\nDescription: " + layer.Description);
        }
        catch (System.Exception ex)
        {
          DRXNET.SDS.SDSMethods.PrintF("\n" + ex.Message);
          DRXNET.SDS.SDSMethods.PrintF("\n" + ex.StackTrace);
        }
      }
    }


MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: NET Party with Bricscad.
« Reply #3 on: March 05, 2008, 11:58:54 PM »
W00t indeed, coming along nicely Daniel. Da swamp is a rockin' tonight with neato experimental stuff; kudos you guys.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #4 on: March 06, 2008, 10:02:05 AM »
Thank You, Just having a bit of fun  :-o

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #5 on: March 06, 2008, 10:04:39 AM »
fun with forms

Code: [Select]
   [CommandMethodAttribute("doit")]
    public static void test5()
    {
      TestForm form = new TestForm();
      DRXNET.OdAp.Application.ShowModalForm(form);
    }

Code: [Select]
  public partial class TestForm : Form
  {
    AcadApplication app;
    AcadDocument doc;
    AcadDatabase db;
    AcadSummaryInfo suminfo;
    public TestForm()
    {
      InitializeComponent();
      app = (AcadApplication)DRXNET.OdAp.Application.ComApplication;
      doc = app.ActiveDocument;
      db = doc.Database;
      suminfo = db.SummaryInfo;
    }
    private void button1_Click(object sender, EventArgs e)
    {
      this.Close();
    }
    private void TestForm_Load(object sender, EventArgs e)
    {
      this.textBoxTitle.Text = suminfo.Title;
      this.textBoxSubject.Text = suminfo.Subject;
      this.textBoxAuthor.Text = suminfo.Author;
      this.textBoxCategory.Text = "MIA";
      this.textBoxKeyWords.Text = suminfo.Keywords;
      this.richTextBoxComments.Text = suminfo.Comments;
    }
    private void TestForm_FormClosed(object sender, FormClosedEventArgs e)
    {
      suminfo.Title = this.textBoxTitle.Text;
      suminfo.Subject = this.textBoxSubject.Text;
      suminfo.Author = this.textBoxAuthor.Text;
      suminfo.Keywords = this.textBoxKeyWords.Text;
      suminfo.Comments = this.richTextBoxComments.Text;
    }
  }

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #6 on: March 09, 2008, 10:03:07 AM »
Here is the latest,

Put these three DLLs in your Bricscad support folder
Appload the DRXNET_2.04_8.DLL the other two will be loaded on demand

You can use the new netload command to load your assemblies, or with lisp (netload_ “path”)

When setting up your .NET projects, reference these three DLL’s and set copy local to false.

I have also attached a sample C# solution, (VS2008 Express)


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #7 on: March 09, 2008, 10:06:38 AM »
more samples

Code: [Select]

[CommandMethodAttribute("DrawCircle1")]
    public static void DrawCircle1()
    {
      SDSResultBuffer rb = new SDSResultBuffer();
      rb.Add(new TypedValue(0, "circle"));
      rb.Add(new TypedValue(62, 5));
      rb.Add(new TypedValue(10, new SDSPoint(0.0, 0.0, 0.0)));
      rb.Add(new TypedValue(40, 10));
      SDSMethods.EntMake(rb);
    }

    [CommandMethodAttribute("DrawCircle2")]
    public static void DrawCircle()
    {
      //new way to get COM instance
      AcadApplication app = (AcadApplication)DRXNET.OdAp.Application.ComApplication;
      if (app == null)
      {
        DRXNET.SDS.SDSMethods.PrintF("\n" + "Doh");
      }
      DRXNET.OdGe.Point3d pt1 = new DRXNET.OdGe.Point3d(0, 0, 0);
      AcadDocument Doc = app.ActiveDocument;
      AcadDatabase Db = Doc.Database;
      AcadCircle myCircle = Db.ModelSpace.AddCircle(pt1.ToArray(), 12);
      myCircle.color = ACAD_COLOR.acCyan;
      myCircle.Update();
    }

    [CommandMethodAttribute("addlayout")]
    public static void addlayout()
    {
      //new way to get COM instance
      AcadApplication app = (AcadApplication)DRXNET.OdAp.Application.ComApplication;
      if (app == null)
      {
        DRXNET.SDS.SDSMethods.PrintF("\n" + "Doh");
      }
      AcadDocument Doc = app.ActiveDocument;
      AcadLayout myLayout = Doc.Layouts.Add("MyLayout");
    }

    [CommandMethodAttribute("myosmode")]
    public static void myosmode()
    {
      //new way to get COM instance
      AcadApplication app = (AcadApplication)DRXNET.OdAp.Application.ComApplication;
      if (app == null)
      {
        DRXNET.SDS.SDSMethods.PrintF("\n" + "Doh");
      }
      AcadDocument Doc = app.ActiveDocument;
      Doc.SetVariable("OSMODE", 191);
    }

 
    [CommandMethodAttribute("myplolyline")]
    public static void myplolyline()
    {
      try
      {
        //new way to get COM instance
        AcadApplication app = (AcadApplication)DRXNET.OdAp.Application.ComApplication;
        if (app == null)
        {
          DRXNET.SDS.SDSMethods.PrintF("\n" + "Doh");
        }
        AcadDocument Doc = app.ActiveDocument;
        AcadDatabase Db = Doc.Database;
        Point2dCollection ptcollection = new Point2dCollection();
        ptcollection.Add(new Point2d(0, 0));
        ptcollection.Add(new Point2d(0, 100));
        ptcollection.Add(new Point2d(100, 100));
        ptcollection.Add(new Point2d(100, 0));
        ptcollection.Add(new Point2d(0, 0));
        List<double> vertexList = new List<double>(10);
        ptcollection.ForEach(p => vertexList.AddRange(p.ToArray()));
        AcadLWPolyline pline = Db.ModelSpace.AddLightWeightPolyline(vertexList.ToArray());

        object omin;
        object omax;
        pline.GetBoundingBox(out omin, out omax);
        double[] min = (double[])omin;
        double[] max = (double[])omax;
        pline.Rotate(new double[] { (max[0] - min[0]), (max[1] - min[1]) }, 0.785398163);
        pline.Update();

      }
      catch (System.Exception ex)
      {
        DRXNET.SDS.SDSMethods.PrintF("\n" + ex.Message);
        DRXNET.SDS.SDSMethods.PrintF("\n" + ex.StackTrace);
      }
    }

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: NET Party with Bricscad.
« Reply #8 on: March 09, 2008, 06:11:05 PM »
Looks like you've been having fun!
I'm a bit too snowed under at the moment to join the fun but I will get there soon, keep up the good work!
"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: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #9 on: March 09, 2008, 09:04:52 PM »
Hi Mick,
jump in any time! Since there is access to entities via SDS and COM, I’ve decided to wrap the geometry classes first
I’m about halfway done with these classes.

Code: [Select]
OdGeVector2d
OdGePoint2d
OdGeMatrix2d
OdGeVector3d
OdGePoint3d
OdGeMatrix3d

I figure the best way for me to learn an API like DRX is to wrap it,
It forces me to explore every nook ‘n’ cranny. Could take me a few years though  :-o

Helios

  • Guest
Re: NET Party with Bricscad.
« Reply #10 on: March 10, 2008, 05:52:45 AM »
Was trying to APPLOAD DRXNET_2.04_8.DLL  into V8.2.2 Pro but that fails.

I'm new to DRX/SDS but familiar with Bricscad //Acad COM interface.
Currently swapping to .NET C#, trying to find out how to control Bricscad  in a smart (fast) way.

Is the whole key of this DRX/SDS the creation of in-process DLL's?
We need to transfer large amounts of data in/out of a DWG.

TIA.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #11 on: March 10, 2008, 06:15:29 AM »
Was trying to APPLOAD DRXNET_2.04_8.DLL  into V8.2.2 Pro but that fails.

I'm new to DRX/SDS but familiar with Bricscad //Acad COM interface.
Currently swapping to .NET C#, trying to find out how to control Bricscad  in a smart (fast) way.

Is the whole key of this DRX/SDS the creation of in-process DLL's?
We need to transfer large amounts of data in/out of a DWG.

TIA.



Hi, Helios & welcome to the Swamp

I have Version 8.1.19 installed on my computer with is the latest shown on the Bricscad site, May ask I where did you got 8.2.2?

Strait DRX will give the best performance, the .NET wrappers that I have written for SDS should be fairly quick, using COM though C# probably would not be any faster than VBA, but that depends on what kind of data your manipulating.

PS are you getting any errors with you load the DLLs?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #12 on: March 10, 2008, 07:18:21 AM »
Helios, can you check your version again and make sure it’s not 8.0.22
These DLL’s would not compatible with anything less than version number 8.1.XXX  as there was a compiler change

Thanks  :-)


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #13 on: March 10, 2008, 09:41:12 AM »
After running a few benchmarks, I found that both COM and SDS ran approximately the same speed, strait DRX was almost twice as fast, and I also ported the DRX over to ObjectARX, where AutoCAD just kicked the carp out of DRX :doa:
« Last Edit: March 10, 2008, 09:59:50 AM by Daniel »

Helios

  • Guest
Re: NET Party with Bricscad.
« Reply #14 on: March 10, 2008, 03:11:21 PM »
Hi Daniel,

thanks for replying.
It's V8.2.2 for sure, I'm a Bricscad Beta tester and get pre-release versions to play with.(Currently 8.1.19-1 is online)
My experience with a VB COM link is that it's dead slow, approx. 10 times slower than VBA which runs inside BricsCad.(Or Acad)
I also have learned that it's important to compile VB routines/programs for the correct Bricscad versions or it'll cause heaps of problems.
Hence my question: does DRX get loaded INTO the Bricscad application? Then I can immagine the comparable speed with VBA.
I've played with ActiveX VB6 DLL's which do the same thing.
Any documentation I can look at to get started?

Helios.