We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Graphisoft Resource Compiler: how to set up macros

Sam Karli
Enthusiast

ResConv.exe doc mentions that macros can be defined using [-d <ID1>] [-d <ID2>] [...] [-d <IDn>] formula.

I'm making experiments with it and couldn't make it work.
The command line looks like this:

<Command Condition="'$(BuildType)'=='Debug'">"$(ACDevKitSupport)\Tools\Win\ResConv.exe" -m r -D WINDOWS -T W -q utf8 1252 -i "RINT\$(ProjectName).grc" -D _DEBUG -D COMPANY_NAME="$(CompanyName)" -o "$(OutDir)\RO\$(ProjectName).grc.rc2"</Command>

But this (and many variations for this) doesn't work. What is the decipherment of this enigma?

BTW for me the #include in .grc files don't work, neither, see https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-include-not-working/...

GDL/Python/C++ dev
1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Hi Sam,

 

The ResConv.doc help is not very clear about it, but I think you can only define if a variable as a flag and check if it's there with "#ifdef".

I don't think you can give it an actual value like you did and then use that value.

 


@Sam Karli wrote:

BTW for me the #include in .grc files don't work, neither, see https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-include-not-working/...


I can't answer in that thread since it's locked, so I'm answering here. I don't think that the issue is with #includes, but that you are using the substitution wrong. First of all, the substitution of defined macros happens not during the ResConv.exe step but later using the Windows Resource Compiler (rc.exe).
And second, APP_NAME is not substituted there because the substitution you are trying doesn't work in strings. (and I also think that it's wrong to use "@"-signs around the defined macro).
What would work is to substitute numbers like this:

#define NUMBER_MACRO 32520  // This could also be in an include file
//...
'STR#' NUMBER_MACRO "Prompt strings" {
/* [ ] */ "This has to be a fixed string before it goes to ResConv.exe"
/* [ ] */ "This too"
}

But I guess that won't help in your case.

Now from your questions I'm guessing that you want variable strings in your resources. I see two options:

  1. Do some string replacement processing even before the ResConv.exe step.
    I do this for my "APP_NAME" in my projects. But I'm using CMake configure and so the specifics won't help in your case. So you'll have to research how to do that for Visual Studio projects/solutions.
  2. Define the string with the intention to do the substitution later in the code. So something like this:
    // This is the resource file
    'STR#' 32520 "Prompt strings" {
    /* [ ] */ "The following will be replaced: %s"
    /* [ ] */ "Normal String"
    }​

     

    // This is some code file where you access the resource
    GS::UniString format;
    RSGetIndString (&format, 32520, 1, ACAPI_GetOwnResModule ());
    GS::UniString substitutedString = GS::UniString::Printf (format, "MySuperAppName");
    // Substituted string should now be "The following will be replaced: MySuperAppName"

 

Hope that helps!

Bernd

View solution in original post

3 REPLIES 3
Solution

Hi Sam,

 

The ResConv.doc help is not very clear about it, but I think you can only define if a variable as a flag and check if it's there with "#ifdef".

I don't think you can give it an actual value like you did and then use that value.

 


@Sam Karli wrote:

BTW for me the #include in .grc files don't work, neither, see https://community.graphisoft.com/t5/Archicad-C-API/Graphisoft-Resource-Compiler-include-not-working/...


I can't answer in that thread since it's locked, so I'm answering here. I don't think that the issue is with #includes, but that you are using the substitution wrong. First of all, the substitution of defined macros happens not during the ResConv.exe step but later using the Windows Resource Compiler (rc.exe).
And second, APP_NAME is not substituted there because the substitution you are trying doesn't work in strings. (and I also think that it's wrong to use "@"-signs around the defined macro).
What would work is to substitute numbers like this:

#define NUMBER_MACRO 32520  // This could also be in an include file
//...
'STR#' NUMBER_MACRO "Prompt strings" {
/* [ ] */ "This has to be a fixed string before it goes to ResConv.exe"
/* [ ] */ "This too"
}

But I guess that won't help in your case.

Now from your questions I'm guessing that you want variable strings in your resources. I see two options:

  1. Do some string replacement processing even before the ResConv.exe step.
    I do this for my "APP_NAME" in my projects. But I'm using CMake configure and so the specifics won't help in your case. So you'll have to research how to do that for Visual Studio projects/solutions.
  2. Define the string with the intention to do the substitution later in the code. So something like this:
    // This is the resource file
    'STR#' 32520 "Prompt strings" {
    /* [ ] */ "The following will be replaced: %s"
    /* [ ] */ "Normal String"
    }​

     

    // This is some code file where you access the resource
    GS::UniString format;
    RSGetIndString (&format, 32520, 1, ACAPI_GetOwnResModule ());
    GS::UniString substitutedString = GS::UniString::Printf (format, "MySuperAppName");
    // Substituted string should now be "The following will be replaced: MySuperAppName"

 

Hope that helps!

Bernd

Sam Karli
Enthusiast

Thanks for Your detailed answer,

some thoughts:

-using cmake seems to be a good idea since Graphisoft is moving towards this approach (see devkit/Examples). Unfortunately I'm absolutely a beginner in this topic but this is a strong argument that I should pick this up

-regarding "@SOME_MACRO@"-style stuff, I've seen this in a live code (but didn't work for me), but I think the developer is in my network and can say how it worked.

 

Thanks

Sam

GDL/Python/C++ dev

Hi Sam,

 

- I think CMake is definitely worth the investment. Especially if you want to compile your Add-Ons for both macOS and Windows.

 

- The  "@SOME_MACRO@" stuff is actually how you can do substitution in CMake via the configure_file function.

 

Best,

Bernd