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

AutoPalette

8 REPLIES 8
Reply
Message 1 of 9
Nawara17
308 Views, 8 Replies

AutoPalette

Hi everyone,
im using C# and autocad2006. i search everywhere to find a solution to my problem but i didn't.
i know how to create palettes using C# and load the project in autocad and then call the commandMethod to display the palette. but what i want is to create an exe project and within this project i want to open autocad and display the palettes without call command Method from autocad, i want to display the palette automatically when the autocad opened.
i don't want to do it using script files.

this is my code to display the palette without command Method:
public static void LoadingAutoCAD()
{
CloseAllInstance();
gbl_app = new Autodesk.AutoCAD.Interop.AcadApplicationClass();
gbl_doc = ClsGlobal.gbl_app.ActiveDocument;
gbl_app.Visible = true;
LoadPalette();
}
public static void LoadPalette()
{
if (MyPalette == null)
{
MyPalette = new Autodesk.AutoCAD.Windows.PaletteSet("My Palette");
MyPalette.Style = PaletteSetStyles.ShowTabForSingle;
MyPalette.Opacity = 90;
MyPalette.MinimumSize = new System.Drawing.Size(300, 300);
MyCtrl = new UserMenu();\\this is the user control
MyPalette.Add("My viewer", MyCtrl);
}
MyPalette.Visible=true;
}


i don't know whats the matter with this code, it has no errors but when i execute the code it reaches
MyPalette = new Autodesk.AutoCAD.Windows.PaletteSet("MyPalette"); and then stops. everything after this statment is not be executed.

can anyone help, please.
and thanks in advanced.
8 REPLIES 8
Message 2 of 9
Nawara17
in reply to: Nawara17

Nobody could answer.
just want to know if is it possible??
Message 3 of 9
NathTay
in reply to: Nawara17

It often takes more than a couple of hours to get a response.

The following example removes status bar panes when the dll is loaded.

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Windows

Public Class Class1
Implements IExtensionApplication

Public Sub Initialize() Implements IExtensionApplication.Initialize
Application.StatusBar.RemoveDefaultPane(DefaultPane.DynamicUcs)
Application.StatusBar.RemoveDefaultPane(DefaultPane.Grid)
Application.StatusBar.RemoveDefaultPane(DefaultPane.LayoutIcon)
Application.StatusBar.RemoveDefaultPane(DefaultPane.LayoutMoreIcon)
Application.StatusBar.RemoveDefaultPane(DefaultPane.LineWeight)
Application.StatusBar.RemoveDefaultPane(DefaultPane.ModelIcon)
Application.StatusBar.RemoveDefaultPane(DefaultPane.ObjectTrack)
Application.StatusBar.RemoveDefaultPane(DefaultPane.Polar)
Application.StatusBar.RemoveDefaultPane(DefaultPane.Snap)
End Sub

Public Sub Terminate() Implements IExtensionApplication.Terminate

End Sub

End Class


Regards - Nathan
Message 4 of 9
Nawara17
in reply to: Nawara17

Hello Nathan,
thanks for your reply. but I thing that you did not get what i mean. (becuase of my bad english--->Sorry for that)

i am trying to connect my executable file with the autocad.

acually Myproject.exe executes as following:
1. it displays the login form.
2. after entering the correct data it will display my logo form while it is creating its object instances and then opening autocad.
3. then it should display My usercontrol palette - which is a class in myproject.exe- within the opened autocad.(in step 2)

and this is part of my code, i dont know why it is not working:
public static void LoadingAutoCAD()
{
CloseAllInstance();
gbl_app = new Autodesk.AutoCAD.Interop.AcadApplicationClass();
gbl_doc = ClsGlobal.gbl_app.ActiveDocument;
gbl_app.Visible = true;
LoadPalette();
}
public static void LoadPalette()
{
if (MyPalette == null)
{
MyPalette = new Autodesk.AutoCAD.Windows.PaletteSet("My Palette");
MyPalette.Style = PaletteSetStyles.ShowTabForSingle;
MyPalette.Opacity = 90;
MyPalette.MinimumSize = new System.Drawing.Size(300, 300);
MyCtrl = new UserMenu();\\this is the user control
MyPalette.Add("My viewer", MyCtrl);
}
MyPalette.Visible=true;
}

that is my problem??
can you help?? Please. Message was edited by: Nawara17
Message 5 of 9
Nawara17
in reply to: Nawara17

Hi again,

OK can i solve this problem by accessing the palatte that it is already opened in the autocad app.
is there any function that retreives the autocads palette??

thanks in advance
Message 6 of 9
Anonymous
in reply to: Nawara17

Since you are using COM interop to interact with AutoCAD, I do not think you
can access Palette (built-in or your custom one) from your app, because the
Palette does not expose their interface via COM. However, you may be able to
expose your Palette made in Object ARX .NET API to COM (I haven't done
anything like that, someone may correct me if I am wrong).

As for your previous post, I guess that you did not load your Palette into
AutoCAD, that is, the Palette, as an ObjectARX object, must be loaded and
run in the same process as AutoCAD runs, not the process of your app
(remeber that you are using COM Automation, your app and AutoCAD run on
their own processes, the two communicate across the processes). You must use
"NETLOAD" command to load the ObjectARX .NET component into AutoCAD first.
Once the component is loaded, then this is another issue whether you can
control it (Show/Hide) via COM. Without "NETLOAD" it, there is no chance
your code will work.

One way I can think of to load the .NET dll automatically is add a list
statement in acad.lsp that call 'NETLOAD" command to load your .NET .DLL
whenever AutoCAD starts. Then you can concentrate on how to control
(Show/Hide) your Palette via COM, if you can make it possible.

IMO, automate AutoCAD is only useful when you need some AutoCAD's
functionality from your app but you do not need user to pay attention to
AutoCAD. If you need user to interact with AtuoCAD, automate Acad is not a
very good way. I'd rather have user run AutoCAD as the main program and do
something (your app does) from there. Is this could be your situation?
(because you want ot start Acad and show specific Palette to get user's
attention.)


wrote in message news:5230720@discussion.autodesk.com...
Hi again,

OK can i solve this problem by accessing the palatte that it is already
opened in the autocad app.
is there any function that retreives the autocads palette??

thanks in advance
Message 7 of 9
Anonymous
in reply to: Nawara17

Darn AutoLISP raising it's pesky head again! Will we ever be rid of it? 😉
Message 8 of 9
Anonymous
in reply to: Nawara17

Using acad.lsp is simple way to load ARX (including ARX .NET DLL via
"NETLOAD" command) when AutoCAD start. Actually, you can get rid of this by
modify certain Windows Registries under AutoDesk's key to load ARX/.NET ARX
DLL automatically when Acad starts.

I never did that, but I know it is doable. There might be post(s) on this
regard in this NG.

Of course, modifying Registry is not recommended for average user. With
acad.lsp, it is so simple and easy, there is not need to take risk of
changing Windows Registry in most cases, unless it is absolutely necessary.

I know it may be pain if you never taoched AutoLISP. I haven't do LISP thing
since VBA available, and I even have difficulty to remember correct lisp
syntex for

(command)
( command "NETLOAD"...?)

But, it can be worked out easily by consulting the Help document or
others...


"James Buzbee" wrote in message
news:5231802@discussion.autodesk.com...
Darn AutoLISP raising it's pesky head again! Will we ever be rid of it? 😉
Message 9 of 9
Nawara17
in reply to: Nawara17

thanks guys for these answers. i solve that problem by creating the whole system by using palettes and instead of creating .exe login form i created it by .dll login palette 🙂
i know that was stupid solution but for me it make sense 😄

BTW, Norman can i ask you what do you mean by "I'd rather have user run AutoCAD as the main program and do
something (your app does) from there. Is this could be your situation?
(because you want ot start Acad and show specific Palette to get user's
attention.)"

i dont have another choise, i want to read and write from/to DWG.
I know that RealDWG does that for me and i can use it in .net as an activeX. but we have to buy both AutoCAD and RealDWG. it should come free with autocad. am i right??

and i don't want to buy both, cuase i am just a student i want to build my senior project using autocad. and i am not planning to sell it after that. Nawara17

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