Author Topic: Menu items from net  (Read 4368 times)

0 Members and 1 Guest are viewing this topic.

Bryco

  • Water Moccasin
  • Posts: 1883
Menu items from net
« on: August 06, 2009, 02:41:00 PM »
Using vba a typical menuitem would have a command ^C^C_-vbarun TSs01000x00750x065
where -vbarun is a command call to run a sub from a loaded dvb and TSs01000x00750x065 is the name of a sub within that.

Do I have to use [CommandMethod("TSs01000x00750x065")]  to achieve the same thing using C#?
there are 1000's of these to convert

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Menu items from net
« Reply #1 on: August 06, 2009, 02:49:12 PM »
I think the short answer is yes.  That is what I have done so far
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Menu items from net
« Reply #2 on: August 06, 2009, 02:49:55 PM »
But I think your looking for ^C^CTSs01000x00750x065
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Menu items from net
« Reply #3 on: August 06, 2009, 02:50:29 PM »
You might be able to search and replace the -vbarun with nothing
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Glenn R

  • Guest
Re: Menu items from net
« Reply #4 on: August 06, 2009, 03:51:06 PM »
Bryco,

Without more information, I agree with Duh. Having said that, I have a few thoughts.

1. I can only assume by the naming convention of the sub-routine, that it inserts a door?
2. You do not state if you're wanting to port all the 1000's of sub's to .NET code...is this the case?
3. Can you post one of these subs?

With the conjecture above, I can think of several options, but I need more information.

Cheers,
Glenn.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Menu items from net
« Reply #5 on: August 06, 2009, 04:16:59 PM »
Thanks  for the replies.
The Menu is for metal shapes, where TS stands for tube steel and s stands for square (or rectangular)
TSr stands for round tubesteel
In vba the sub is
Code: [Select]
Sub TSs01000x00750x065()
    ParseBlockname "TSs01000x00750x065"
End Sub
where  ParseBlockname parses the string TSs01000x00750x065 into 1"X3/4" 16ga or .065" wall.
Then the block is made (there is no library of drawings) from this info, and inserted.
So as you say David the menu would be ^C^CTSs01000x00750x065
but I think I need to have [CommandMethod("TSs01000x00750x065") in the C# to make each one a command.

Glenn I was hoping that I could pass an argument from the menu, something I could never figure out in vba.

Glenn R

  • Guest
Re: Menu items from net
« Reply #6 on: August 06, 2009, 04:27:52 PM »
Aha! I thought it was doors but it's steel, but the same principle applies.

As far as passing an arg to a VBA subroutine from the commandline, you can't do it, as the sub acad runs needs to be public and accept no arguments.

If this was me, I would write a function in .NET and decorate it with the 'LispFunction' attribute (or whatever it's called - late here and I'm tired). This function would accept a string argument and then process that from there, rather like your ParseBlockName VBA func already does.

So you would call it like so from your menu item:

(DoSomeFunkySteelMojoWhiteBoy "1000x00750x065")

Make sense?
« Last Edit: August 06, 2009, 04:40:36 PM by Glenn R »

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Menu items from net
« Reply #7 on: August 06, 2009, 04:32:57 PM »
So as you say David the menu would be ^C^CTSs01000x00750x065
but I think I need to have [CommandMethod("TSs01000x00750x065") in the C# to make each one a command.
Yes, and yes.  I originally thought you asked one question, but later talked myself into you asking a different question
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Menu items from net
« Reply #8 on: August 06, 2009, 04:35:54 PM »
Glenn, that is cool.  I have not done that yet, but it gives me some good ideas.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Menu items from net
« Reply #9 on: August 06, 2009, 04:42:37 PM »
Sounds good Glenn, I am testing below as well

Code: [Select]
[CommandMethod("TSs")]
        public void TubeSteel()
        {
            Document doc = acadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptStringOptions pso = new PromptStringOptions("yada");
            PromptResult pr=ed.GetString(pso);
            if (pr.Status != PromptStatus.OK) return;
            string sBlockname = pr.StringResult;
            ed.WriteMessage(sBlockname);
           
        }

So far this may work,
with a menu item w/ macro ^C^C TSS 6543  cad prints 6543 so perhaps this will also work

Glenn R

  • Guest
Re: Menu items from net
« Reply #10 on: August 06, 2009, 04:46:34 PM »
I should clarify:

You can't pass an argument to a VBA subroutine that you're callling with VBARUN. You could, however, execute a VBASTMT (I think that's what it's called) to execute any VBA statement on the commandline.

So you could probably do this in your menu item (not tested - just off the top of my head):

^^CVBASTMT ParseBlockName "TSs01000x00750x065"

However, I would strongly advise against this. For one, it's relying on commandline syntax and two, it's VBA ;)

Glenn R

  • Guest
Re: Menu items from net
« Reply #11 on: August 06, 2009, 04:49:19 PM »
Sounds good Glenn, I am testing below as well

Code: [Select]
[CommandMethod("TSs")]
        public void TubeSteel()
        {
            Document doc = acadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptStringOptions pso = new PromptStringOptions("yada");
            PromptResult pr=ed.GetString(pso);
            if (pr.Status != PromptStatus.OK) return;
            string sBlockname = pr.StringResult;
            ed.WriteMessage(sBlockname);
           
        }

So far this may work,
with a menu item w/ macro ^C^C TSS 6543  cad prints 6543 so perhaps this will also work

I wouldn't do that, as it's relying on nothing else being printed to the commandline...

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Menu items from net
« Reply #12 on: August 06, 2009, 05:37:38 PM »
Glenn
I'm done with vba. (Hopefully)
I have tried VBASTMT only to crash.

I'll look into the lispfunction (the word lisp affects me like vba does you)
as you say it sounds more robust

Glenn R

  • Guest
Re: Menu items from net
« Reply #13 on: August 07, 2009, 05:45:42 AM »
I actually have no problem with VBA. I use the right tool for the right job (or at least try to).

VBA is being phased out so to speak, so it's a good idea to move away from it.

I do think 'lisp function' is the best option in this case. Let me know how it goes.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Menu items from net
« Reply #14 on: August 07, 2009, 06:12:38 PM »
So far I've just got it all to work.
Code: [Select]
[CommandMethod("TSs")]
        public void TubeSteel()
        {
            Document doc = acadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptStringOptions pso = new PromptStringOptions("");

            PromptResult pr=ed.GetString(pso);
            if (pr.Status != PromptStatus.OK) return;
           
            string sBlockname = pr.StringResult;
            MetalMenu.Metal.ParseBlockname(sBlockname);
           
        }

This is not using the lisp yet, I am trying this as it seems to be exactly the same as scripting:  circle 0,0,0 4.
With a menu macro ^C^CTSS TSs00375x00375x065   the escape should guarantee (I guess I should use ^C^C^C ) no unwanted input.
However, entering after the command doesn't reissue the full command but only TSS (The actual command)
So this is a no go, I'ld rather have a Commandmethod for every item.
Here's hoping the lisp version will work.