VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can you run a SUB Procedure from command line???

5 REPLIES 5
Reply
Message 1 of 6
INTOOCAD
186 Views, 5 Replies

Can you run a SUB Procedure from command line???

I want to run a sub procedure and pass it a couple of argumnents from the command line or new toolbar button.
Is this possible? Any workarounds?
Any help is appreciated!

Thanks!
John M.
5 REPLIES 5
Message 2 of 6
Wayneth
in reply to: INTOOCAD

You can do this with -VBARUN follwed by the
name of the sub. Or, you can define a sub as
an autoCAD command in a routine:

(defun c:[yourACADCommandName]()
(command "-vbarun" "[yourSubName]")
)
Message 3 of 6
Anonymous
in reply to: INTOOCAD

John,
This one is a little tricky. You cannot send arguments to a macro, so
you have to fake it out a little and read the additional information from
the command line. Here is a little snippet from one of my apps to check a
discipline setting:

Dim strParam1 as string
Dim strDispDir as String

'Check the passed parameter to ensure a discipline setting
strParam1 = ThisDrawing.Utility.GetString(False)
If strParam1 = "" Then
MsgBox "You need to supply a discipline parameter."
Else
strDispDir = "G:\dept\acad\" & strParam1
End If


The GetString method is the important one. If the argument(s) that you are
passing contains spaces, you will need to use .GetString(True) and you will
need to end the string with a return. In my case, I am just sending a single
word. . You can also add a prompt after the "True" or "False".

I then have a menu setup for the different disciplines like so:

^C^C-vbarun g:/cad/acad2000/macros/mymacro.dvb!Checkdisp Arch

This calls the Sub 'Checkdisp' from the mymacro.dvb and sends "Arch" as an
argument.

Rich Tiede
CAD Manager/Developer
Sear-Brown


"jmartens" wrote in message
news:f11a568.-1@WebX.maYIadrTaRb...
I want to run a sub procedure and pass it a couple of argumnents from the
command line or new toolbar button.
Is this possible? Any workarounds?
Any help is appreciated!
Thanks!
John M.
Message 4 of 6
INTOOCAD
in reply to: INTOOCAD

Richard-

Thanks for the reply!!

Four words for you my friend!!

YOU ARE THE MAN!!

Worked slick as a whistle.....that one stumped me for about 5 hours and led to major frustration....should have looked outside the box I guess...huh??

Thanks again, your help is greatly appreciated!!

John M.
Message 5 of 6
Anonymous
in reply to: INTOOCAD

may be i don't understand your tasks, but it is possible to call macros with
parameters (from commandline) using

_vbastmt
.("")

as example:
_vbastmt
HMap.HMapExecute("!UNLOAD_DLL")

regards, alfred


"Richard Tiede" schrieb im Newsbeitrag
news:6F4268989C306D0D50A45DB0ADDE68FC@in.WebX.maYIadrTaRb...
> John,
> This one is a little tricky. You cannot send arguments to a macro, so
> you have to fake it out a little and read the additional information from
> the command line. Here is a little snippet from one of my apps to check a
> discipline setting:
>
> Dim strParam1 as string
> Dim strDispDir as String
>
> 'Check the passed parameter to ensure a discipline setting
> strParam1 = ThisDrawing.Utility.GetString(False)
> If strParam1 = "" Then
> MsgBox "You need to supply a discipline parameter."
> Else
> strDispDir = "G:\dept\acad\" & strParam1
> End If
>
>
> The GetString method is the important one. If the argument(s) that you are
> passing contains spaces, you will need to use .GetString(True) and you
will
> need to end the string with a return. In my case, I am just sending a
single
> word. . You can also add a prompt after the "True" or "False".
>
> I then have a menu setup for the different disciplines like so:
>
> ^C^C-vbarun g:/cad/acad2000/macros/mymacro.dvb!Checkdisp Arch
>
> This calls the Sub 'Checkdisp' from the mymacro.dvb and sends "Arch" as an
> argument.
>
> Rich Tiede
> CAD Manager/Developer
> Sear-Brown
>
>
> "jmartens" wrote in message
> news:f11a568.-1@WebX.maYIadrTaRb...
> I want to run a sub procedure and pass it a couple of argumnents from the
> command line or new toolbar button.
> Is this possible? Any workarounds?
> Any help is appreciated!
> Thanks!
> John M.
>
>
Message 6 of 6
INTOOCAD
in reply to: INTOOCAD

Alfred-

Thanks for your response!! That works great as well!
I appreciate your time and help from everyone!!

Hard to believe that from this little excersize, I have learned alot!! ha ha

THANKS!
John M.

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

Post to forums  

Autodesk Design & Make Report

”Boost