Skip to main content
1-Visitor
February 4, 2010
Question

Can you pass parameters to a macro

  • February 4, 2010
  • 2 replies
  • 7485 views
I'm used to a different macro programming language in which you can have 1 macro do several different things by passing parameter(s) along with the macro name - e.g. macro_name 'yes' The macro then declares the parameter(s) e.g. parameter yes_no The parameter yes_no is then a variable yes_no with a value of 'yes' The macro then uses this variable to determine an action later on. For example, I have a macro that changes a drawing and saves it down again, but I now find I want a very similar macro that does everything except save the drawing down again. With a parameter, I could include an if statement in the macro to either save the drawing or not depending on the value of the parameter. Otherwise I will have to either copy the macro twice or split it into bits and run as separate macros Is there something similar to this in Isodraw? I have looked but can't find anything, though the terminology may be different.

    2 replies

    12-Amethyst
    February 4, 2010
    I'm not sure how you are planning to specify the parameter. My approach is to basically break it apart as you mention. It can be done at a high level though. Have a global variable that is set and then basically three macros. 1) Your main macro with the addition of an "if" statement surrounding your save down coding. For our purposes let's refer to this as a submacro called "Change_and_Maybe_Save_Down" (long, but descriptive). 2 & 3) Something similar to this...
    209c292858
    and then another such as...
    209c292858
    Then just check the value of this variable in your if statement used in Change_and_Maybe_Save_Down.
    TimSharp1-VisitorAuthor
    1-Visitor
    February 4, 2010
    Yes this is a good way of doing it. A global variable will do the same job as a parameter. Unfortunately I always compare things to ME10 and try to do things a similar way - I programmed ME10 for over 20 years so it's ingrained!
    1-Visitor
    February 5, 2010

    In IsoDraw 7.1 you can pass parameters to submacros like this:

    SubMacro Change_drawing( Boolean save_down )
    If ( save_down ) Then
    # Change and Save Down ...
    Else
    # Change only ...
    End If
    End SubMacro

    Macro Test_Change_drawing
    Run Change_drawing( true )
    # or
    Run Change_drawing( false )
    End Macro

    1-Visitor
    July 20, 2010

    Hi,

    Actually I have two problems about this topic :

    - First, I can't see the code examples quoted in this topic, all I can see is :

    In IsoDraw 7.1 you can pass parameters to submacros like this:

    d008373291

    - Next, I really need to pass parameters to a macro, but in a command line like this :

    C:\Program Files\PTC\Arbortext IsoDraw 7.1\Program\IsoDraw71.exe file.cgm -macro macroName(parameter)

    The PTC support told me that was possible, but they are not able to tell me how to write the macro to get the parameters. I tried several ways :

    -> Macro macroName(String param) : I have a 'parameter error ""'
    -> Macro macroName(define param as String) : isodraw crashes
    -> Macro macroName(param) : isodraw crashes

    Can anyone help me, please?

    Thanks

    Damien

    12-Amethyst
    July 20, 2010

    In regards to the code not being visible, it appears that when they updated to this new forum format they lost anything marked as code as well as many of the attachments.

    I've attached what I was given from PTC support about running from the cmd line. I've used it quite a bit, but don't recall anything showing the possibility of specifying a parameter. Can you explain what you are attempting to do in more detail? The more specific, the better.

    1-Visitor
    July 21, 2010

    First of all, thank you for your instant answer!

    About the code quotes, I already had your embeded text file from PTC support, but thank you.

    Here are my needs:

    - Open automatically a lot of cgm files (more than 2000)

    - Create several active areas in each cgm files at some exact places defined in an other file.

    - Save each cgm file

    I tried several ways to reach my needs :

    - I found a way in this forum to read a text file in a variable and so get the information about the active areas. But Isodraw is not enough robust to bear so much charge. I had some random bad behaviour, with or without the collection treatment.

    - Now, I'm making a java program which will read the information about the active areas and I would like to launch from this Java program, a macro having as parameter the information about the active area and let Isodraw do only its job : create the active area.

    - Waiting for an answer about parameters, I'm trying to create from my java program a new macro file for each cgm file which will create all the active areas, and launch it.

    Any idea?

    Thanks again.

    ps : Benno, I just saw your answer, I think I already tried this solution, it wasn't working. I'll try again to be sure, thanks anyway.