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

0 Members and 1 Guest are viewing this topic.

Helios

  • Guest
Re: Bricscad && .NET
« Reply #90 on: September 10, 2010, 04:25:22 AM »
Daniel,

I managed to track a few lost RxNet.Dll's but that didn't solve the problem, even after a restart.
This is my path:
D:\\VOSS.NET\\VOSS\\VOSS.CAD.Bricscad.RxNet\\bin\\Debug\\VOSS.CAD.Bricscad.RxNet.dll
I also tried
D:\VOSS.NET\VOSS\VOSS.CAD.Bricscad.RxNet\bin\Debug\VOSS.CAD.Bricscad.RxNet.dll

Manually it loads ok.
Any other sugestions on how to autoload the .NET dll?

Here's an other question:
I made a routine which optionally will prompt the user for a filename.
Now by specifying two entry points in the DLL I was hoping to make the call in two ways.

Command 'WriteArea' should produce a save dialog
Command '_WriteArea' should do an autosave without a save dialog.

It seems the '_' is ignored? Both calls show the flag is 'false'
Changing '_WriteArea' to 'WriteAreaAuto' does the trick, I just thought it was a nice shortcut.

Arno


 [CommandMethod("_WriteArea")]
    public static void _WriteArea()
    {
      DoWriteArea(true);
    }

    [CommandMethod("WriteArea")]
    public static void WriteArea()
    {
      DoWriteArea(false);
    }
   
    private static void DoWriteArea(bool autoSave)
    {
      try
      {
        RxNet.RxGlobal.GlobalFunctions.Printf("\nThe flag passed is : {0}", autoSave);
        //some work is done here....
      }
      catch (System.Exception ex)
      {
        RxNet.RxGlobal.GlobalFunctions.Printf("\n{0}\n{1}", ex.Message, ex.StackTrace);
      }
    }


Helios

  • Guest
Re: Bricscad && .NET
« Reply #91 on: September 10, 2010, 10:00:19 AM »
Never mind the other question.
Changed the underscore to - (minus).
Works.... :kewl:

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #92 on: September 13, 2010, 05:45:00 PM »
It's a path issue,  it's looking for the loader file in "system drive\programs folder\RxNet\v9\"
Also, I it's probably not a good idea to rename\repath the module,  this will cause demand-loading to fail
I will see what I can do to make finding the loader file a bit easier. Let me know if you need a custom version setup.

Helios

  • Guest
Re: Bricscad && .NET
« Reply #93 on: September 21, 2010, 10:22:26 AM »
Hi Daniel,

keeping the 'path' issue for what it is at this moment, I think I've run into something more complex.

What I'm trying to do is incorporating some crude number crunching to a RxNet.dll, for example exporting a lot of entity information to a file.
Let's say I gave such a command [CommandMethod("DoIt")]  :laugh: so after NetLoading the DLL I type DoIt at the command prompt and voila, magic happens.
Now I want to automate this as part of a larger process and use an ordinary COM link to the Application.ActiveDocument and call SendCommand("DoIt") to trigger the RxNet.dll.
Bad luck, bad luck, what I think is happening is this:
The COM SendCommand holds a reference (and locks?) the ActiveDocument.
When Rx tries to start the DoIt() it also tries to get a connection to the same ActiveDocument, but that fails since and external process is busy with it.  ( That's at least how it feels)
Am I correct in my observation? And if so, how do I send a command or is there an other way to start the RxNet routine?

I was reviewing the presentation of Prodok at this years conference in Brugge, also mentioning DeadLocking COM calls.
Is that a way to go?

TIA,
Arno

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #94 on: September 21, 2010, 12:20:35 PM »
IMO, sendcommand is probably not the best approach, its asynchronous and you may run into other issues down the road. 
Ideas,

1, call the function directly from the other module

2, If you must use COM, you can expose your commands to COM by coding a interface, I think it's fairly simple.

3, use the [Lispfunction] attribute and call the function via lisp.

#1 is the best choice if the other modules are .NET.

Thoughts?

iraklis

  • Guest
Re: Bricscad && .NET
« Reply #95 on: September 22, 2010, 03:09:07 AM »
Hi Daniel,

I have tried to create a command using VB.NET but does not work. It seems that there is not the <CommandMethod("xxx")> attribute. Is there any solution for this?


Best regards

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #96 on: September 22, 2010, 06:14:19 AM »
make sure the class is public and static, make sure the function is also public and static and it should work : )
« Last Edit: September 22, 2010, 06:18:00 AM by __declspec »

Helios

  • Guest
Re: Bricscad && .NET
« Reply #97 on: September 22, 2010, 06:43:49 AM »
Daniel,

I think I have to go through the COM option (2) since I want to call/start certain RxNet methods from an external process.
I have Bricscad running, along my own .Net application.
Do you have a few clues on how to approach this?
It's not typical Cad related, more a general .Net topic I realize.

I imagine something like the RxNet.Dll being loaded in Bricscad.
Through Marshal.GetActiveObject("Bricscad.RxNet") I get a reference to the RxNet DLL
It exposes funcionality through an interface (so the Rxnet class is no longer static?)

Anybody else out here who is familiar with building COM dll's?

Arno
  

iraklis

  • Guest
Re: Bricscad && .NET
« Reply #98 on: September 22, 2010, 07:15:27 AM »
Well I still can not find the <CommandMethod("xxx")> attribute for VB.NET   :-(

Has anyone successfully created a custom command using VB.NET?


Thanks

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #99 on: September 22, 2010, 08:41:02 AM »
Well I still can not find the <CommandMethod("xxx")> attribute for VB.NET   :-(

Has anyone successfully created a custom command using VB.NET?


Thanks

works here   :-)

Code: [Select]
Imports BricscadApp
Imports BricscadDb
Imports RxNet.ApplicationServices
Imports RxNet.Runtime

Public Class Class1
  <CommandMethod("doit")> _
  Public Shared Sub runit()
    Try
      RxNet.RxGlobal.GlobalFunctions.Alert("Hello From VB")
    Catch ex As System.Exception
      MsgBox(ex.Message)
    Finally
    End Try
  End Sub
End Class


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #100 on: September 22, 2010, 08:42:18 AM »
Daniel,

I think I have to go through the COM option (2) since I want to call/start certain RxNet methods from an external process.
I have Bricscad running, along my own .Net application.
Do you have a few clues on how to approach this?
It's not typical Cad related, more a general .Net topic I realize.

I imagine something like the RxNet.Dll being loaded in Bricscad.
Through Marshal.GetActiveObject("Bricscad.RxNet") I get a reference to the RxNet DLL
It exposes funcionality through an interface (so the Rxnet class is no longer static?)

Anybody else out here who is familiar with building COM dll's?

Arno
  

Arno, I will have to think about this a bit.

Helios

  • Guest
Re: Bricscad && .NET
« Reply #101 on: September 22, 2010, 08:51:37 AM »
It's 'just' an entry point I need.  :wink:
On the other hand, it would also be usefull to be able to pass a few variables tino a method.
I had begun putting data in USERR1, USERS1 etc and have them read by RxNet 'at the other side of the wall'.
Works, but maybe there's a much smoother way.

Awaiting your thoughts,

ttyl

jgr

  • Guest
Re: Bricscad && .NET
« Reply #102 on: September 22, 2010, 10:11:31 AM »
I converted the example RxNetPlay to VB.NET
http://www.theswamp.org/index.php?topic=29100.msg351970#msg351970

But Nativemethods.entSel generates an exception.

Code: [Select]
Friend Shared Function entSel(ByVal message As String) As RxNet.DatabaseServices.ObjectId

    Dim name(1) As Long
    Dim pt(2) As Double
    acedEntSel(message, name, pt)

    ' This generate System.OverflowException
    Return New RxNet.DatabaseServices.ObjectId(CInt(name(0)))
End Function

(Using win xp, Bricscad v10.4.8. .Net 2.0.)

Can anyone help me?

Thanks.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #103 on: September 22, 2010, 10:58:25 AM »
maybe you need to allocate the memory? I.e

Code: [Select]
Friend Shared Function entSel(ByVal message As String) As RxNet.DatabaseServices.ObjectId
Dim name As Long() = New Long(1) {}
Dim pt As Double() = New Double(2) {}
acedEntSel(message, name, pt)
Return New RxNet.DatabaseServices.ObjectId(CInt(name(0)))
End Function


Dan


Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Bricscad && .NET
« Reply #104 on: September 22, 2010, 11:03:18 AM »

[off Topic]

Daniel, you win:  my curiosity required a Bing of “Brugse Zot”.

 [proceed as normal]
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.