.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can't find ModelessOperationWill Start Event in Dot net

20 REPLIES 20
SOLVED
Reply
Message 1 of 21
JanetDavidson
1490 Views, 20 Replies

Can't find ModelessOperationWill Start Event in Dot net

Hello everybody. Hope somebody could help me

In objectArx  Editor  object has  ModelessOperationWillStart . But how could I use this in my vb net ?

ObjectBrowser doesn't show it ?!!!

Janet.

 

20 REPLIES 20
Message 2 of 21
norman.yuan
in reply to: JanetDavidson

I believe modelessOperationWillStart() is an ObjectRAX's AcEditorReactor class' methos, which is only available since Acad2013. It is not exposed to ObjectARX .NET API (as we all know that not everything in ObjectARX is exposed in its .NET API). thus you do not find it in the Object Browser.

Message 3 of 21


@norman.yuan wrote:

I believe modelessOperationWillStart() is an ObjectRAX's AcEditorReactor class' methos, which is only available since Acad2013. It is not exposed to ObjectARX .NET API (as we all know that not everything in ObjectARX is exposed in its .NET API). thus you do not find it in the Object Browser.


Norman! This method (modelessOperationWillStart) available starting with version AutoCAD 2000 (!!!) but not yet exposed in .NET

Without ObjectARX there is no way to have modelessOperation notification.

 

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 4 of 21

Well, I am not very familiar with ObjectARX. But that method and/or the class (the method's owner) have been renamed in Acad2013. In this snse, one can say it is only available in Acad2013. Just like, there is a class called Person with method Run, in early version. Then in new version you rename the class Person to Human (for good or bad reasons). So, you cannot say Human.Run(0 exists since beginning in regard to programming API.

Message 5 of 21
JanetDavidson
in reply to: norman.yuan

it is really a pain.

 I like to check if user change block  attributes in Properties Window (palette) . and I don't want to have an objectmodify event all the time running . that is a shame we can't do this using API.

Janet

 

Message 6 of 21


@norman.yuan wrote:

Well, I am not very familiar with ObjectARX. But that method and/or the class (the method's owner) have been renamed in Acad2013. In this snse, one can say it is only available in Acad2013. Just like, there is a class called Person with method Run, in early version. Then in new version you rename the class Person to Human (for good or bad reasons). So, you cannot say Human.Run(0 exists since beginning in regard to programming API.


Sorry, Norman, but you're wrong! The name of class (and base class) and name of method and parameters are the same in ObjectARX 2000 and 2013. The only difference is that this function in AutoCAD 2000 exported from acad.exe, and in 2013 from accore.dll. I skip "unicode revolution" in AutoCAD 2007.

//
// ObjectARX SDK 2000
// file aced.h
//
class AcEditorReactor: public AcRxEventReactor 
{ 
public:
//// skiped
    virtual void modelessOperationWillStart(const char* contextStr);
    virtual void modelessOperationEnded(const char* contextStr);
//// skiped
};

//
// ObjectARX SDK 2013
// file aced.h
//

class AcEditorReactor: public AcRxEventReactor 
{ 
public:
//// skiped
    virtual void modelessOperationWillStart(const ACHAR* contextStr);
    virtual void modelessOperationEnded(const ACHAR* contextStr);
//// skiped
};

 You admit your mistakeSmiley Happy

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 7 of 21

Janet!

What about user change attribute(s) not from properties palette but (for example) with help of command _ATTEDIT  ?

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 8 of 21

Hi again Alex and Norman.

I took care at that part (attedit) .  I  am watching  commandstart event, If it is attedit then I start  objectmodify event and if the object being modified is target block, I do necessary things I need to do . But for properties palette there is no command to catch. So basically I have to have objectmodify , on,  to watch the database all the times. there is big impact on database in my application.

Janet

Message 9 of 21

Janet. Are you ready to create arx-file (ie study C++ and ObjectARX) , which help you to check object was modified from OPM or no?

If your's answer is NO, than single solution is objectmodify event, which must be simplest in order to speed up AutoCAD.

If your's answer is YES, I can help you in ObjectARX discussion group.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 10 of 21

I've attach arx-files which exported function:

int IsOPMChangeProps();

This function can be P/Invoke from .NET (C#, VB.NET, etc.) Solution is for AutoCAD 2010...2012

[DllImport("OPMTest2010x32.arx",CallingConvention = CallingConvention.Cdecl, EntryPoint = "IsOPMChangeProps")]
private static int IsOPMChangeProps2010x32();
[DllImport("OPMTest2010x64.arx",CallingConvention = CallingConvention.Cdecl, EntryPoint = "IsOPMChangeProps")]
private static int IsOPMChangeProps2010x64();

arx-file must be loaded with help of call:

// For x86 (x32)
SystemObjects.DynamicLinker.LoadModule("OPMTest2010x32.arx", false, false);
// For x64
SystemObjects.DynamicLinker.LoadModule("OPMTest2010x64.arx", false, false);

But objectModified event must being active because this function can check status but not event (reactor).  

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 11 of 21

Hi Alex,

Oh my God , You are so caring. I had a moving this weekend and couldn't check on internet the whole 3 days.

Right now I am back on track. Still I didn't get into your posts but I  will . Just wanted to let you know I  am really

appreciated . I will look and If I have question I will ask you for sure if you don't mind.

Thanks you so much for your help Alex.

Janet.

 

 

Message 12 of 21

Hi Again Alex . I didn't understand one word of c++ code you provided, It is my fault , no offence , I am not that smart .  I said to myself   let's just use Alex's Arx compiled file  and implement it in my project. Below code  is what I did . But it doesn't work. what did I do wrong ? .

 

Let me rephrase myself to avoid any confustion.

this is how  I implement this for Attedit command. When commandStart triggers . If the command is Attedit I add handler for objectmodify event.

If object had any changes then I do my stuff . And then when CommandEnded  triggers ,I remove ObjectModify handler.

so basically Commandstart and Commandend events always running. But ObjectModify doesn't run always.

 

Now let's go back to your solution for properties palette. How would I know user start changing an atrribute so I active the objectmodify event ?

Please give me some light here . Thanks.

 

 

 

 

 

 

 

  Public Sub Initialize() Implements IExtensionApplication.Initialize
      SystemObjects.DynamicLinker.LoadModule("c:\OPMTest2010x64.arx", False, False)
       Properties_palette_changed_helper.Start_monitoring_pallette()
    End Sub
    Public Sub Terminate() Implements IExtensionApplication.Terminate
    End Sub



Public Class Properties_palette_changed_helper
    <DllImport("OPMTest2010x64.arx", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="IsOPMChangeProps")> _
    Private Shared Function IsOPMChangeProps2010x64() As Integer
    End Function
    Public Shared Sub Start_monitoring_pallette()
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(vbLf & IsOPMChangeProps2010x64.ToString)
    End Sub
End Class

 

Message 13 of 21

Hi, Janet!

You do not understand me. The function that I wrote allows you to check whether the entity has changed with the Properties Palette (OPM) or not. But it is not an event and does not allow him to subscribe to the event.
If you are not interested in how the entity has been changed - you do not need this function.
In order to make the event ModelessOperationWillStart / ModelessOperationEnd need to write .NET wrapper with Mixed C++, what I'm not an expert. Sorry!

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 14 of 21

Anyways. At least you look into it. That is nice of you.

Maybe somebody else  from autodesk help us. Now is the time we see lack of Tony Tanzilla in this forum .

So many unanswered question.

Cheers Janet.

 

Message 15 of 21

Hi Janet!

I've found solution without mixed C++. Try it. I've attached two solution. First - create arx-files (OPMTest2010x32.arx and OPMTest2010x64.arx). Second - create .NET-assembly which use arx-files (from first solution) in order to set own event handlers.

using System;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;

// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(COPMEvent.MyCommands))]

namespace COPMEvent
{

    // This class is instantiated by AutoCAD for each document when
    // a command is called by the user the first time in the context
    // of a given document. In other words, non static data in this class
    // is implicitly per-document!
    public class MyCommands
    {
        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
        public delegate void OPMChangeEvent();

        [DllImport("OPMTest2010x32.arx", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SetOPMChangeStart")]
        private static extern void SetOPMChangeStart32(OPMChangeEvent callBackFunc);
        [DllImport("OPMTest2010x64.arx", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SetOPMChangeStart")]
        private static extern void SetOPMChangeStart64(OPMChangeEvent callBackFunc);
        [DllImport("OPMTest2010x32.arx", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SetOPMChangeStop")]
        private static extern void SetOPMChangeStop32(OPMChangeEvent callBackFunc);
        [DllImport("OPMTest2010x64.arx", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SetOPMChangeStop")]
        private static extern void SetOPMChangeStop64(OPMChangeEvent callBackFunc);

        private static void SetOPMChangeStart(OPMChangeEvent callBackFunc)
        {
            if (IntPtr.Size == 4) SetOPMChangeStart32(callBackFunc);
            else SetOPMChangeStart64(callBackFunc);
        }
        private static void SetOPMChangeStop(OPMChangeEvent callBackFunc)
        {
            if (IntPtr.Size == 4) SetOPMChangeStop32(callBackFunc);
            else SetOPMChangeStop64(callBackFunc);
        }

        private void OPMChangeEventStart()
        {
            // For testing only
            Application.ShowAlertDialog("OPMEventStart - Begin Editing");
        }
        private void OPMChangeEventStop()
        {
            // For testing only
            Application.ShowAlertDialog("OPMEventStop - Stop Editing");
        }

        private static OPMChangeEvent callBackFuncStart = null;
        private static OPMChangeEvent callBackFuncStop = null;
        // Modal Command with localized name

        
        [CommandMethod("SetOPMEvent")]
        public void SetOPMEvent() // This method can have any name
        {
            callBackFuncStart = new OPMChangeEvent(OPMChangeEventStart);
            callBackFuncStop  = new OPMChangeEvent(OPMChangeEventStop);
            SetOPMChangeStart(callBackFuncStart); SetOPMChangeStop(callBackFuncStop);
        }

        [CommandMethod("ResetOPMEvent")]
        public void ResetOPMEvent() // This method can have any name
        {
            callBackFuncStart = null;
            callBackFuncStop = null;
            SetOPMChangeStart(callBackFuncStart); SetOPMChangeStop(callBackFuncStop);
        }


    }

}

Select any entity and try change it with Properties Palette.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 16 of 21

Hi Alex.

I really don't know how to make it up to you , for all your consideration. Thanks

 

I tried to convert your code to vb. ( using those online translators.

the only part I  couldn't translate is

 

  

    [CommandMethod("SetOPMEvent")]
        public void SetOPMEvent() // This method can have any name
        {
            callBackFuncStart = new OPMChangeEvent(OPMChangeEventStart);
            callBackFuncStop  = new OPMChangeEvent(OPMChangeEventStop);
            SetOPMChangeStart(callBackFuncStart); SetOPMChangeStop(callBackFuncStop);
        }

 

 

 

 

 

 

 

 

 I am pretty sure you can handle vb if you know C# and c++

 

I just know vb

 

Thanks again Alex.

Regards,

Janet.

 

 

Message 17 of 21

With help of http://www.developerfusion.com/tools/convert/csharp-to-vb/ you can get the same as I:

Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
 
' This line is not mandatory, but improves loading performances
<Assembly: CommandClass(GetType(COPMEvent.MyCommands))> 
 
Namespace COPMEvent
 
    ' This class is instantiated by AutoCAD for each document when
    ' a command is called by the user the first time in the context
    ' of a given document. In other words, non static data in this class
    ' is implicitly per-document!
    Public Class MyCommands
        <UnmanagedFunctionPointer(CallingConvention.Cdecl)> _
        Public Delegate Sub OPMChangeEvent()
 
        <DllImport("OPMTest2010x32.arx", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="SetOPMChangeStart")> _
        Private Shared Sub SetOPMChangeStart32(callBackFunc As OPMChangeEvent)
        End Sub
        <DllImport("OPMTest2010x64.arx", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="SetOPMChangeStart")> _
        Private Shared Sub SetOPMChangeStart64(callBackFunc As OPMChangeEvent)
        End Sub
        <DllImport("OPMTest2010x32.arx", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="SetOPMChangeStop")> _
        Private Shared Sub SetOPMChangeStop32(callBackFunc As OPMChangeEvent)
        End Sub
        <DllImport("OPMTest2010x64.arx", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="SetOPMChangeStop")> _
        Private Shared Sub SetOPMChangeStop64(callBackFunc As OPMChangeEvent)
        End Sub
 
        Private Shared Sub SetOPMChangeStart(callBackFunc As OPMChangeEvent)
            If IntPtr.Size = 4 Then
                SetOPMChangeStart32(callBackFunc)
            Else
                SetOPMChangeStart64(callBackFunc)
            End If
        End Sub
        Private Shared Sub SetOPMChangeStop(callBackFunc As OPMChangeEvent)
            If IntPtr.Size = 4 Then
                SetOPMChangeStop32(callBackFunc)
            Else
                SetOPMChangeStop64(callBackFunc)
            End If
        End Sub
 
        Private Sub OPMChangeEventStart()
            ' For testing only
            Application.ShowAlertDialog("OPMEventStart - Begin Editing")
        End Sub
        Private Sub OPMChangeEventStop()
            ' For testing only
            Application.ShowAlertDialog("OPMEventStop - Stop Editing")
        End Sub
 
        Private Shared callBackFuncStart As OPMChangeEvent = Nothing
        Private Shared callBackFuncStop As OPMChangeEvent = Nothing
        ' Modal Command with localized name
 
 
        <CommandMethod("SetOPMEvent")> _
        Public Sub SetOPMEvent()
            ' This method can have any name
            callBackFuncStart = New OPMChangeEvent(AddressOf OPMChangeEventStart)
            callBackFuncStop = New OPMChangeEvent(AddressOf OPMChangeEventStop)
            SetOPMChangeStart(callBackFuncStart)
            SetOPMChangeStop(callBackFuncStop)
        End Sub
 
        <CommandMethod("ResetOPMEvent")> _
        Public Sub ResetOPMEvent()
            ' This method can have any name
            callBackFuncStart = Nothing
            callBackFuncStop = Nothing
            SetOPMChangeStart(callBackFuncStart)
            SetOPMChangeStop(callBackFuncStop)
        End Sub
 
 
    End Class
 
End Namespace

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 18 of 21

Alex,

you are incredible. Now in vb editor I am error free.

I ran the command and right after I hit enter

I get this


************** Exception Text **************
System.EntryPointNotFoundException: Unable to find an entry point named 'SetOPMChangeStart' in DLL 'OPMTest2010x64.arx'.
   at VBOPMEvent.COPMEvent.MyCommands.SetOPMChangeStart64(OPMChangeEvent callBackFunc)
   at VBOPMEvent.COPMEvent.MyCommands.SetOPMEvent() in C:\VBOPMEvent\myCommands.vb:line 69
   at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()

 

 

and Alex line 69 is this line

SetOPMChangeStop(callBackFuncStop)

 

 

my system is 2012 64 bit.

 

Cheers,

Janet.

 

 

Message 19 of 21

Are you sure you used the correct version of OPMTest2010x64.arx?
I just rechecked with AutoCAD 2012 x64 - no errors.

The correct version is: http://forums.autodesk.com/autodesk/attachments/autodesk/152/28761/2/OPMTest.zip

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 20 of 21

Don't kill me  Alex,

you were right.

Sorry . I am a girl .

 

You are really my hero.

I think autodesk should be proud of you.

 

It works like a charm

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost