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

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #15 on: March 10, 2008, 09:49:26 PM »
Yes, I believe DRX  is running “in process”,  The whole theory is that, the ODA’s DRX SDK can manipulate the DWG database directly in a similar way ObjectARX does, thus I would expect that DRX would be much faster than VBA. We could probably run a few benchmarks to test this theory.

The only supporting documentation for DRX is what comes with the DRX SDK,
http://opendesign.com/node/127
and what comes with Bricscad, in the API folder.

My guess is that they have changed something in the beta version that your running, I hoped they have moved to the latest and greatest version of the ODA libraries. 

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #16 on: March 11, 2008, 02:31:46 AM »
Hi, Jerry .... question from the Bricscad fourm

Thanks for trying this out, It seems that I do need to do a little work on SDSMethods.SSget. Anyway without seeing your code it’s hard to see where the problem is. I have written a couple of samples in C# showing the difference between using my SDS wrappers and the COM wrappers. I’ll post this over at the Swamp too so other can see.


Code: [Select]
//com sample
    [CommandMethodAttribute("MySel1")]
    public static void MySel1()
    {
      try
      {
        AcadApplication app = (AcadApplication)DRXNET.OdAp.Application.ComApplication;

        if (app == null)
          DRXNET.SDS.SDSMethods.PrintF("\n" + "Doh");

        AcadDocument Doc = app.ActiveDocument;
        AcadSelectionSet selection = Doc.SelectionSets.Add("test");

        try
        {
          int[] var = new int[] { 0 };
          object[] val = new object[] { "POINT" };
          selection.SelectOnScreen(var, val);

          List<AcadPoint> entlist = new List<AcadPoint>();
          Point3dCollection ptlist = new Point3dCollection();

          foreach (var e in selection)
            entlist.Add((AcadPoint)e);

          entlist.ForEach(e => ptlist.Add(new Point3d((double[])e.Coordinates)));
          ptlist.ForEach(p => DRXNET.SDS.SDSMethods.PrintF(p.ToString()));
        }
        catch
        {
          DRXNET.SDS.SDSMethods.PrintF("\nError Getting Selection set: ");
        }
        finally
        {
          selection.Delete();
        }
      }
      catch (System.Exception ex)
      {
        DRXNET.SDS.SDSMethods.PrintF("\n" + ex.Message);
        DRXNET.SDS.SDSMethods.PrintF("\n" + ex.StackTrace);
      }
    }

    //sds sample
    [CommandMethodAttribute("MySel2")]
    public static void MySel2()
    {
      try
      {
        Point3dCollection ptlist = new Point3dCollection();
        SDSResultBuffer filter = new SDSResultBuffer();
        filter.Add(new TypedValue(0, "POINT"));
        SDSName ss = SDSMethods.SSGet(null, filter);

        if (ss.ID0 == 0 && ss.ID1 == 0)
          DRXNET.SDS.SDSMethods.PrintF("\nError Getting Selection set: ");

        for (int i = 0; i < SDSMethods.SSLength(ss); i++)
        {
          SDSName entname = SDSMethods.SSName(ss, i);
          SDSResultBuffer entlist = SDSMethods.EntGet(entname);
          foreach (TypedValue tv in entlist)
          {
            if (tv.TypeCode == 10)
              ptlist.Add(new Point3d((SDSPoint)tv.Value));
          }
        }
        ptlist.ForEach(p => DRXNET.SDS.SDSMethods.PrintF(p.ToString()));
        SDSMethods.SSFree(ss);
      }
      catch (System.Exception ex)
      {
        DRXNET.SDS.SDSMethods.PrintF("\n" + ex.Message);
        DRXNET.SDS.SDSMethods.PrintF("\n" + ex.StackTrace);
      }
    }

Helios

  • Guest
Re: NET Party with Bricscad.
« Reply #17 on: March 12, 2008, 04:34:33 AM »
Thanks Daniel,

I've downloaded the DRXsdk and have a go with that.
I'll have a play with your tools on V8.1.19.

Helios.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #18 on: March 21, 2008, 11:47:37 PM »
I’ve attached new DLLs that should be compatible with Bricscad 8.2.XXX
The new DLLs are compiled against the ODA’s DRX 2.05 libraries




files moved
« Last Edit: August 27, 2008, 09:40:27 PM by Daniel »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #19 on: March 26, 2008, 04:12:42 AM »
 :laugh:

Code: [Select]
//com sample
    [CommandMethodAttribute("extractattribute")]
    public static void extractattribute()
    {
      DateTime TimeStart = DateTime.Now;
      string FileNamePath = @"c:\EvalReport_02.txt";

      StreamWriter LogFile_Obj =
        new StreamWriter(FileNamePath, true, System.Text.Encoding.ASCII);

      LogFile_Obj.AutoFlush = true;
      LogFile_Obj.WriteLine("Starting eval...");

      int countAtts = 0;

      try
      {
        AcadApplication app = DRXNET.OdAp.Application.ComApplication as AcadApplication;

        if (app == null)
          DRXNET.SDS.SDSMethods.PrintF("\n" + "Doh");

        AcadDocument Doc = app.ActiveDocument;
        AcadDatabase db = Doc.Database;

        foreach (AcadObject e in db.ModelSpace)
        {
          if (e.ObjectName == "AcDbBlockReference")
          {
            AcadBlockReference blockReference = (AcadBlockReference)e;

            if (blockReference.HasAttributes == true && blockReference.Layer == "1_8_TEXT")
            {
              foreach (AcadAttributeReference attributeReference in
                blockReference.GetAttributes() as Object[])
              {
                countAtts++;
                LogFile_Obj.WriteLine(countAtts.ToString() + '\t' +
                      attributeReference.TagString + '\t' + attributeReference.TextString);

              }
            }
          }
        }
        TimeSpan TimeDuration = (DateTime.Now - TimeStart);

        DRXNET.SDS.SDSMethods.PrintF("\nProcess time: " +
          TimeDuration.TotalSeconds.ToString());

        LogFile_Obj.WriteLine(("End eval...Process time: " +
          TimeDuration.TotalSeconds.ToString() + " Seconds"));

      }
      catch (System.Exception ex)
      {
        DRXNET.SDS.SDSMethods.PrintF("\n" + ex.Message);
        DRXNET.SDS.SDSMethods.PrintF("\n" + ex.StackTrace);
      }
      finally
      {
        LogFile_Obj.Close();
      }
    }
« Last Edit: March 26, 2008, 04:36:45 AM by Daniel »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: NET Party with Bricscad.
« Reply #20 on: March 26, 2008, 04:24:34 AM »
Hi Dan !

AcadApplication ????
       AcadDocument Doc = app.ActiveDocument;
        AcadDatabase db = Doc.Database;

seems to be a little polution in the namespaces and types ? 
 :|

that code looks familiar on several levels  :-)





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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #21 on: March 26, 2008, 04:45:54 AM »
Hi Dan !

AcadApplication ????
       AcadDocument Doc = app.ActiveDocument;
        AcadDatabase db = Doc.Database;

seems to be a little polution in the namespaces and types ? 
 :|



I know,  I think it used to be IcadApplication, but that changed when some of the clones started using the OpenDWG libraries to access the database

BTY the time was about 3 seconds  :-D
« Last Edit: March 26, 2008, 05:36:34 AM by Daniel »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #22 on: March 26, 2008, 05:37:34 AM »
that code looks familiar on several levels  :-)

And it should, I lifted most of it from you  :-o
I hope you don’t mind  :?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: NET Party with Bricscad.
« Reply #23 on: March 26, 2008, 06:00:05 AM »
that code looks familiar on several levels  :-)

And it should, I lifted most of it from you  :-o
I hope you don’t mind  :?

don't be silly ;-) 
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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #24 on: April 17, 2008, 10:41:20 AM »
Here are some new DLLs. Kudos to Bricscad for fixing the issues with mixed managed/unmanaged modules . these are for 8.2.8++

« Last Edit: August 27, 2008, 01:51:25 PM by Daniel »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #25 on: May 06, 2008, 02:15:28 PM »
Here are some new DLL’s to play with. 
The way I was passing strings between managed & unmanaged memory was flawed, I think I have this fixed.
GetVar() and SetVar() now consume/return a boxed object instead of a result buffer, I did this so I could delete the unmanaged resources quickly
I did some work on the ObjectId Class that wraps OdDbObjectId, It now has constructors and operators to translate between SDSName, ActiveX ObjectId (long) and OdDbObjectId

example

Code: [Select]
    [CommandMethodAttribute("doit1")]
    public static void doit1()
    {
      AcadApplication app = (AcadApplication)DRXNET.OdAp.Application.ComApplication;
      if (app == null)
        DRXNET.SDS.SDSMethods.PrintF("\n" + "Doh");

      AcadDocument Doc = app.ActiveDocument;
      AcadSelectionSet selection = Doc.SelectionSets.Add("test");

      SDSResultBuffer buff = null;

      try
      {
        int[] var = new int[] { 0 };
        object[] val = new object[] { "LWPOLYLINE" };

        selection.SelectOnScreen(var, val);

        List<AcadLWPolyline> entlist = new List<AcadLWPolyline>();

        foreach (var e in selection)
          entlist.Add((AcadLWPolyline)e);

        ObjectId id = new ObjectId(entlist[0].ObjectID);//constructor for long int

        DRXNET.SDS.SDSMethods.PrintF("\n" + id.ToString());
        DRXNET.SDS.SDSMethods.PrintF("\n" + id.IsValid.ToString());
        DRXNET.SDS.SDSMethods.PrintF("\n" + id.sdsName.ToString());
   
        buff = SDSMethods.EntGet(id); //implicit operator to sdsname

        DRXNET.SDS.SDSMethods.PrintF("\n" + buff.ToString());
      }
      catch (System.Exception ex)
      {
        DRXNET.SDS.SDSMethods.PrintF("\n" + ex.Message);
        DRXNET.SDS.SDSMethods.PrintF("\n" + ex.StackTrace);
      }
      finally
      {
        selection.Delete();
        buff.Dispose();
      }
    }

still have lots of work todo
« Last Edit: August 27, 2008, 01:50:56 PM by Daniel »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #26 on: August 27, 2008, 02:00:51 PM »
I’ve updated the DLLs , included a version for the new beta (v9)and attached them along with C# solution with a few com samples. Still a work in progress

Instructions:
Put these three DLLs in your Bricscad support folder
Appload the DRXNET_2.0X_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”)

quick sample

Code: [Select]
  [CommandMethod("addlayout")]
    public static void addlayout()
    {
      try
      {
        AcadApplication application = DRXNET.OdAp.Application.AcadApplication as AcadApplication;
        if (application == null)
          throw new System.Exception("Could Not Get Application");

        AcadDocument document = application.ActiveDocument;
        AcadLayout myLayout = document.Layouts.Add("MyLayout");
      }
      catch (System.Exception ex)
      {
        System.Windows.Forms.MessageBox.Show(ex.Message);
      }
    }



Spike Wilbury

  • Guest
Re: NET Party with Bricscad.
« Reply #27 on: August 27, 2008, 02:19:39 PM »
Daniel,

Any idea how the lisp routines are protected, do they have something similar like fas/vlx files now? (with their LispEx)

Just curiosity for now...

Thanks.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: NET Party with Bricscad.
« Reply #28 on: August 27, 2008, 02:26:52 PM »
Daniel,

Any idea how the lisp routines are protected, do they have something similar like fas/vlx files now? (with their LispEx)

Just curiosity for now...

Thanks.

Last I heard, they were working on some sort of encryption mechanism, but I haven’t followed it up.
The New DRX API is pretty slick, I still want to play with BRX too once they get that released. All in all, it’s cool stuff.

Spike Wilbury

  • Guest
Re: NET Party with Bricscad.
« Reply #29 on: August 27, 2008, 02:32:44 PM »
Daniel,

Any idea how the lisp routines are protected, do they have something similar like fas/vlx files now? (with their LispEx)

Just curiosity for now...

Thanks.

Last I heard, they were working on some sort of encryption mechanism, but I haven’t followed it up.
The New DRX API is pretty slick, I still want to play with BRX too once they get that released. All in all, it’s cool stuff.


Thanks.

BRX ?

never mind, found the info here

http://www.deelip.com/2008/03/new-clone-on-block.html
« Last Edit: August 27, 2008, 02:35:56 PM by LE »