Author Topic: Bricscad && .NET  (Read 91287 times)

0 Members and 3 Guests are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #120 on: September 23, 2010, 10:50:48 AM »
Excellent  8-)
Kind of a kludge, but I might setup a couple of XRecords or Dictionaries (in/out) to pass data.

octavio

  • Guest
Re: Bricscad && .NET
« Reply #121 on: September 28, 2010, 02:22:27 PM »
Hi ppl, I just did a application with .NET and it seams to work ok, now I have been wondering how can I tell briscad to load the .net assembly at the startup.
I am new to briscad and lisp but I saw in a lisp example the way they do it is they put the files "on_start.lsp" and "on_doc_load.lsp" at the root of Bricscad. Now I tried to modify those files and I added (load "bsx_netload.lsp"). And that file just has the code (command "netload [assembly-path]"). I tried with the full path and with just the name copying the assembly to the root Bricscad folder but it did not work.

Does any one know how can I load an assembly at the startup?

Thanks in advance.

SimonPapadopoulos

  • Guest
Re: Bricscad && .NET
« Reply #122 on: September 29, 2010, 05:23:32 AM »
Hi! I am new to BricsCAD. I am trying to write into the DWG database some XRecords. I want to write an integer and a string.

I wrote the following code. Is it correct?

Code: [Select]
<CommandMethod("chaos")> _
    Public Shared Sub foit()
        Dim acadapp As AcadApplication = RxNet.ApplicationServices.Application.AcadApplication
        Dim doc As AcadDocument = acadapp.ActiveDocument

        Dim db As AcadDatabase = doc.database

        'get the dictionary collection
        Dim dictCollection As AcadDictionaries = db.Dictionaries

        'create a new dictionary for my data
        Dim dicto As AcadDictionary = dictCollection.Add("myfirstdictionary")

        'create an integer XRecord
        Dim rec1 As AcadXRecord = dicto.AddXRecord("myinteger")
        rec1.SetXRecordData(VariantType.Integer, 16)

        'create a string XRecord
        Dim rec2 As AcadXRecord = dicto.AddXRecord("mystring")
        rec2.SetXRecordData(VariantType.String, "this is a very small string")

        MsgBox("it worked re!! " & dictCollection.Count & " : " & dicto.Count)
        
        'save the changes to the document
        doc.Save()
    End Sub

I wrote another command to read those XRecords but I cannot understand how to use GetXRecordData sub...

Could someone help me? The following code is the command that tries to read the integer and raises many exceptions when GetXRecordData is called..

Code: [Select]
<CommandMethod("maos")> _
    Public Shared Sub doit()
        Dim acadapp As AcadApplication = RxNet.ApplicationServices.Application.AcadApplication
        Dim doc As AcadDocument = acadapp.ActiveDocument

        'open the database
        Dim db As AcadDatabase = doc.database

        'get the dictionary collection
        Dim dictCollection As AcadDictionaries = db.Dictionaries

        'select my custom dictionary
        Dim dicto As AcadDictionary = dictCollection.Item("myfirstdictionary")

        'get my integer record
        Dim rec As AcadXRecord = dicto.Item("myinteger")
        
        Dim komos As Integer
        rec.GetXRecordData(VariantType.Integer, komos)

        MsgBox(komos)
    End Sub

Thank you for your time,
Simon
« Last Edit: September 29, 2010, 05:51:14 AM by SimonPapadopoulos »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #123 on: September 29, 2010, 06:27:29 AM »
Hi ppl, I just did a application with .NET and it seams to work ok, now I have been wondering how can I tell briscad to load the .net assembly at the startup.
I am new to briscad and lisp but I saw in a lisp example the way they do it is they put the files "on_start.lsp" and "on_doc_load.lsp" at the root of Bricscad. Now I tried to modify those files and I added (load "bsx_netload.lsp"). And that file just has the code (command "netload [assembly-path]"). I tried with the full path and with just the name copying the assembly to the root Bricscad folder but it did not work.

Does any one know how can I load an assembly at the startup?

Thanks in advance.

try putting a file called RxLoader.Txt in C:\Program Files\RxNet\V10, inside RxLoader.Txt, put the path to your module

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #124 on: September 29, 2010, 06:48:55 AM »
Hi! I am new to BricsCAD. I am trying to write into the DWG database some XRecords. I want to write an integer and a string.

I wrote the following code. Is it correct?
...


Hi Simon,
I'll take a look after dinner. At first glance, I see you need to may replace VariantType.XXX with the DXF type

octavio

  • Guest
Re: Bricscad && .NET
« Reply #125 on: September 29, 2010, 12:05:01 PM »
Hi ppl, I just did a application with .NET and it seams to work ok, now I have been wondering how can I tell briscad to load the .net assembly at the startup.
I am new to briscad and lisp but I saw in a lisp example the way they do it is they put the files "on_start.lsp" and "on_doc_load.lsp" at the root of Bricscad. Now I tried to modify those files and I added (load "bsx_netload.lsp"). And that file just has the code (command "netload [assembly-path]"). I tried with the full path and with just the name copying the assembly to the root Bricscad folder but it did not work.

Does any one know how can I load an assembly at the startup?

Thanks in advance.

try putting a file called RxLoader.Txt in C:\Program Files\RxNet\V10, inside RxLoader.Txt, put the path to your module

Hi, that worked just right thank you very much. I had been looking for that 2 days and now it working thanks.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #126 on: September 29, 2010, 07:11:55 PM »
FYI, There should be an anemic help file in there  :-)

SimonPapadopoulos

  • Guest
Re: Bricscad && .NET
« Reply #127 on: September 30, 2010, 01:48:17 AM »
Quote
At first glance, I see you need to may replace VariantType.XXX with the DXF type

Hi Daniel,
There no DXF types in your libraries. AutoCAD has its DXF types in enumerators like DXFType.Text = 1.
I put the value 1 (dxftype text) in the SetXRecordData and GetXRecordData subs and it does not work..

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #128 on: September 30, 2010, 03:58:45 AM »
see if this helps you

Code: [Select]
[CommandMethod("execa")]
    public static void execa()
    {
      AcadApplication application = Application.AcadApplication as AcadApplication;
      AcadDocument document = application.ActiveDocument;
      AcadDatabase database = document.database;
      try
      {
        AcadDictionaries dictionaries = database.Dictionaries;
        AcadDictionary dictionary = dictionaries.Add("SWAMP");
        AcadXRecord xRecord = dictionary.AddXRecord("SWAMPEXR");

        List<Int16> types = new List<Int16>();
        List<object> values = new List<object>();

        types.Add(1);
        values.Add("Hola");

        types.Add(1);
        values.Add("Swampers");

        xRecord.SetXRecordData(types.ToArray(), values.ToArray());
      }
      catch (System.Exception ex)
      {
        document.Utility.Prompt(String.Format("\n{0}", ex.Message));
      }
    }

    [CommandMethod("execb")]
    public static void execb()
    {
      AcadApplication application = Application.AcadApplication as AcadApplication;
      AcadDocument document = application.ActiveDocument;
      AcadDatabase database = document.database;
      try
      {
        AcadDictionaries dictionaries = database.Dictionaries;
        AcadDictionary dictionary = dictionaries.Item("SWAMP") as AcadDictionary;
        AcadXRecord xRecord = dictionary.Item("SWAMPEXR") as AcadXRecord;

        object otypes;
        object ovalues;

        xRecord.GetXRecordData(out otypes, out ovalues);

        Int16[] types = (Int16[])otypes;
        object[] values = (object[])ovalues;

        for (int i = 0; i < types.Length; i++)
        {
          document.Utility.Prompt(String.Format("({0} . {1})", types[i], values[i]));
        }

      }
      catch (System.Exception ex)
      {
        document.Utility.Prompt(String.Format("\n{0}", ex.Message));
      }
    }

jgr

  • Guest
Re: Bricscad && .NET
« Reply #129 on: September 30, 2010, 07:59:05 PM »
There any way to get a pointer to the database of the active document?
(database.UnmanagedObject of the AcadApplication.Activedocument? for PInvoke)

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #130 on: September 30, 2010, 08:03:59 PM »
Possibly,  but .NET would only see a IntPtr type.  What are you needing to do?

jgr

  • Guest
Re: Bricscad && .NET
« Reply #131 on: September 30, 2010, 08:20:51 PM »
Thanks for replying.

I would like to use acdbTextFind.

Thanks.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #132 on: October 01, 2010, 12:35:09 AM »
how about I add a global function getWorkingDatabase() as an IntPtr   :-o
sounds dangerous  :laugh:

SimonPapadopoulos

  • Guest
Re: Bricscad && .NET
« Reply #133 on: October 01, 2010, 03:49:59 AM »
Daniel thank you !

The code with the XRecords worked!
Is there a way set Visual Studio to debug with BricsCAD?
This is possible with AutoCAD and speeds up development process..

Thank you for your time,
Simon

Helios

  • Guest
Re: Bricscad && .NET
« Reply #134 on: October 01, 2010, 09:22:05 AM »
Simon,

I netload my RxNet.DLL in Bricscad..
Set the break point(s) in the code and use Tools/Attach to proces in VS to select Bricscad from the list.
Then fire up the command....

Hope this helps,
Arno