Author Topic: .NET Commands into a CUI file?  (Read 4801 times)

0 Members and 1 Guest are viewing this topic.

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
.NET Commands into a CUI file?
« on: April 09, 2018, 02:32:43 PM »
Is there a good way to put all the commands in my app into a CUIX?

My app will have a cuix file with toolbars, a menu, and a ribbon. But the first step is to pull all the commands out of my app into the cuix. So far I have on the order of 60 commands, all in a Commands.cs file.

Right now I’m manually inputting each command into the cuix through the cui command, setting the macro to ^C^Ccommandname, but these leaves room for mistakes. Anyone got a better method?

ChrisCarlson

  • Guest
Re: .NET Commands into a CUI file?
« Reply #1 on: April 09, 2018, 02:50:39 PM »
Aren't the commands loaded automagically when you load the DLL file?

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: .NET Commands into a CUI file?
« Reply #2 on: April 09, 2018, 03:15:28 PM »
I despise cuix files. I'd rather do my menu setup through code. Then I can just grab all the commands in my dll via reflection (as we used to do when creating demand load entries in the registry), sort them by command group, and then create my controls at load time.

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: .NET Commands into a CUI file?
« Reply #3 on: April 09, 2018, 03:18:56 PM »

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Re: .NET Commands into a CUI file?
« Reply #4 on: April 09, 2018, 05:02:55 PM »
Aren't the commands loaded automagically when you load the DLL file?

They are, I'm just looking for a way to expose them to the user via drop down menu or ribbon so the users can discover them easily.

Here's an example of getting the commands in your dll. I think it's what you're after http://through-the-interface.typepad.com/through_the_interface/2009/05/creating-demand-loading-entries-automatically-for-your-autocad-application-using-net.html

Excellent! So you do something like this and build the menu/ribbon at load time instead of messing with a CUIX file? Seems like it might be a good way to go if it doesn't impact startup time too much. CUIX files seem to be a step back from the old mns files IMO.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: .NET Commands into a CUI file?
« Reply #5 on: April 09, 2018, 06:13:52 PM »
One downside to programmatically generating UI content is they don't play nice with workspaces.  Either you end up with all that content in every.single.workspace (which is something *I* despise), or you have to implement some rather extensive coding to ensure that whenever the workspace is saved or restored the custom content does the same thing.  It's annoying to be working in a workspace set up for 3D work (which for me doesn't involve text, dimensions, or other annotations) and having panels for annotation tools keep popping up.

I use some commercial content that generates Ribbons automagically, and most of them are a royal PITA.  One doesn't run properly if you so much as change to a different workspace name.  The other puts in the same content, regardless of workspace or what you are doing - no hiding panels or tabs which don't apply.  And they don't stay put if dragged off from the Ribbon.

If you're going to make this generally available, please think of the users who do, in fact, make use of workspaces.   :angel:
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: .NET Commands into a CUI file?
« Reply #6 on: April 09, 2018, 06:27:36 PM »
One downside to programmatically generating UI content is they don't play nice with workspaces.  Either you end up with all that content in every.single.workspace (which is something *I* despise), or you have to implement some rather extensive coding to ensure that whenever the workspace is saved or restored the custom content does the same thing.

Leave it to the guy with experience to have that insight... I don't utilize workspaces much.

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Re: .NET Commands into a CUI file?
« Reply #7 on: April 09, 2018, 07:10:43 PM »
One downside to programmatically generating UI content is they don't play nice with workspaces...If you're going to make this generally available, please think of the users who do, in fact, make use of workspaces.   :angel:

So you'd rather see a cuix file?

Right now the app (and cuix) are being loaded as part of a .bundle. I haven't looked into how that works with workspaces..
« Last Edit: April 10, 2018, 02:30:02 AM by Atook »

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: .NET Commands into a CUI file?
« Reply #8 on: April 10, 2018, 02:23:02 AM »
I don't know if you can import a .cui file into AutoCAD these days (I think there all .cuix??) but a cui file is just xml, maybe you can read in a csv into an xml file (or just create the xml file, copy paste edit etc), load it to create the .cuix file and use that?

Just a thought :)
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: .NET Commands into a CUI file?
« Reply #9 on: April 10, 2018, 05:07:38 AM »
cui legacy customistaion file 2018.

Copy cuix rename to .zip and open.
A man who never made a mistake never made anything

n.yuan

  • Bull Frog
  • Posts: 348
Re: .NET Commands into a CUI file?
« Reply #10 on: April 10, 2018, 10:07:54 AM »
One downside to programmatically generating UI content is they don't play nice with workspaces.  Either you end up with all that content in every.single.workspace (which is something *I* despise), or you have to implement some rather extensive coding to ensure that whenever the workspace is saved or restored the custom content does the same thing.  It's annoying to be working in a workspace set up for 3D work (which for me doesn't involve text, dimensions, or other annotations) and having panels for annotation tools keep popping up.

While in most cases CUIX would be appropriate, there are cases dynamically code-generated UI (Ribbon UI) might be preferred. For example, my company have a nation-wide unified CAD environment set up for a discipline (a couple of Ribbon tabs), so CAD used from anywhere in can work on projects at anywhere. But there are quite different tools (commands) used by different regions due to regulatory issues. Thus, it would be better to only show the ribbon items related to the project's region. Thus, I have a set of ribbon items generated by code automatically show/hide depending on active drawing's project (its region). In the code, I handle WorkSpaceChanged event to make sure these ribbon items show/hide no matter what WorkSpace user changes.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: .NET Commands into a CUI file?
« Reply #11 on: April 10, 2018, 11:34:31 AM »
One downside to programmatically generating UI content is they don't play nice with workspaces.  Either you end up with all that content in every.single.workspace (which is something *I* despise), or you have to implement some rather extensive coding to ensure that whenever the workspace is saved or restored the custom content does the same thing.  It's annoying to be working in a workspace set up for 3D work (which for me doesn't involve text, dimensions, or other annotations) and having panels for annotation tools keep popping up.

While in most cases CUIX would be appropriate, there are cases dynamically code-generated UI (Ribbon UI) might be preferred. For example, my company have a nation-wide unified CAD environment set up for a discipline (a couple of Ribbon tabs), so CAD used from anywhere in can work on projects at anywhere. But there are quite different tools (commands) used by different regions due to regulatory issues. Thus, it would be better to only show the ribbon items related to the project's region. Thus, I have a set of ribbon items generated by code automatically show/hide depending on active drawing's project (its region). In the code, I handle WorkSpaceChanged event to make sure these ribbon items show/hide no matter what WorkSpace user changes.

+1.  There *are* cases where it's appropriate.  Another example would be the various dynamic/contextual panels in Civil3D, providing users with what they need but otherwise staying out of their face.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Re: .NET Commands into a CUI file?
« Reply #12 on: April 10, 2018, 12:58:37 PM »
...Copy cuix rename to .zip and open.

Today I learned, thanks Al!

Reading all your responses, I think the cuix will be the approach I take. I can think about run time generated ribbons etc. later if I find a need to.

And after looking at the cui files as XML, I think I'll just use the interface in CAD to build one. :)

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: .NET Commands into a CUI file?
« Reply #13 on: April 10, 2018, 05:51:17 PM »
...Copy cuix rename to .zip and open.

Today I learned, thanks Al!

Reading all your responses, I think the cuix will be the approach I take. I can think about run time generated ribbons etc. later if I find a need to.

And after looking at the cui files as XML, I think I'll just use the interface in CAD to build one. :)

Keep it in the back of your mind; I've gone in to replace/remove some cranky icons.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}