Learn to manage BIM workflows and create professional Archicad templates with the BIM Manager Program.
2023-05-13 12:14 AM
Build started...
1>------ Build started: Project: JHP_AutoLoad, Configuration: Release x64 ------
1>Compiling the localized GRC file...
1>JHP_AutoLoad.grc
1>
1>
1>G:Build\x64\Release\\RO\JHP_AutoLoad.grc.rc2.i (29) : Extra character on line (ResID: 32000)
1>
1>Write_Error: Extra character on line (ResID: 32000)
In 1>G:Build\x64\Release\\RO\JHP_AutoLoad.grc.rc2.i (29) : Extra character on line (ResID: 32000)
The drive letter is correct, however the first backslash is missing between G: and Build.
There are two backslashes between Release and RO.
The full path is accurate except for a few folders upstream of Build.
G:<\><folder><\><folder><\><projectname><\>Build\x64\Release\RO
is the real path I am looking for to avoid this error.
I have looked all over Visual Studio and cannot seem to find where to correct this.
Is it even a VS issue?
Any idea what my options are?
Thanks - chris
2023-05-13 01:18 AM - edited 2023-05-13 01:19 AM
I think given the rest of that line is saying
Extra character on line (ResID: 32000)
the file is being loaded fine regardless of the double slash and there is just an error on that line in the grc file for resid 32000 that you need to rectify.
2023-05-13 08:31 AM
the .grc.rc2.i is a file created at compile time. the 'extra character on line' error is misleading, there is probably nothing wrong with your grc file. It probably just means that the compiler can't find one of the resources you created.
check your resourceIds.hpp and addonMain.cpp and make sure that the ids you created for your dialog are correctly placed.
Can't help much without the code, if you can't fix it post these 2 files and the grc.
2023-05-15 06:59 PM
My bad for the lack of information. Friday, when I posted, I was trying to get this out there and leave for the day.
More info:
- - VS 2019, AC25
- - I have a working version of this from VS 2017, AC24
- - I have verified the .svg file is in place and content from individual files in the working 24 project matches content in this 25 project.
Code for the VS2019/AC25 project follows...
JHP_AutoLoadResIDs.hpp:
#ifndef JHP_AUTOLOAD_RESIDS_HPP
#define JHP_AUTOLOAD_RESIDS_HPP
// !max value is (32767)
#define JHP_AUTOLOAD_ABOUT_STRINGSID 32000
#define JHP_AUTOLOAD_MENU_STRINGSID 32500
#define JHP_AUTOLOAD_BPNID 32501
#endif // JHP_AUTOLOAD_RESIDS_HPP
JHP_AutoLoad.cpp:
// ---------------------------------- Includes ---------------------------------
#include "APIEnvir.h"
#include "ACAPinc.h" // also includes APIdefs.h
#include "JHP_AutoLoad.hpp"
#include "JHP_AutoLoadResIDs.hpp"
#include "RS.hpp"
#include "..\..\functions_25.hpp"
#include <shellapi.h>
#include <string>
#include <fstream>
//using namespace std;
// ---------------------------------- Types ------------------------------------
// ---------------------------------- Variables --------------------------------
static void ShowDialog()
{
JHP_AutoLoad_Dialog dialog;
dialog.Invoke();
}
int NoBpn()
{
ShowDialog();
return 0;
}
static bool JHP_DoNotOpenBPN()
{
////
//// Check "FILENAME" for .bpn extension.
////
GS::UniString strFileExtension;
strFileExtension = GetProjectInfo("FILENAME");
if (strFileExtension.EndsWith(".bpn"))
NoBpn();
return false;
}
static GSErrCode __ACENV_CALL JHP_EventHandler(API_NotifyEventID notifID, Int32 /*param*/)
{
GSErrCode err = NoError;
switch (notifID) {
case APINotify_Open:
{
// Loads at model OPEN.
GS::UniString strFileName;
strFileName = (GetProjectInfo("FILENAME"));
API_ProjectInfo projectInfo;
GSErrCode err = ACAPI_Environment(APIEnv_ProjectID, &projectInfo, NULL);
if (err != NoError)
{
ACAPI_WriteReport("\n\nJHP ERROR", false);
return 0;
}
if (projectInfo.untitled == TRUE)
{
ACAPI_WriteReport("\n\nProject file HAS NOT been saved yet", false);
}
else
{
GS::UniString strFileExtension;
strFileExtension = GetProjectInfo("FILENAME");
if (strFileExtension.EndsWith(".bpn")) {
// Project file HAS been saved
std::ofstream objLogFile;
objLogFile.open("K:\\CGilmer\\ArchiCAD_AddOn\\JHP_DoNotOpenBPN.txt", std::ios::out | std::ios::app);
if (objLogFile) {
GS::UniString strTime;
strTime = TimeStamp(2);
char strUser[1024];
DWORD intUserLen = 1024;
GetUserNameA(strUser, &intUserLen);
GS::UniString strReportData;
strReportData = (strTime + GS::UniString(" ") + GS::UniString(strUser) + GS::UniString("\n"));
objLogFile << strReportData.ToCStr();
GS::UniString strFileNameData;
strFileNameData = " " + strFileName + "\n\n";
objLogFile << strFileNameData.ToCStr();
objLogFile.close();
}
std::system("powershell.exe -ExecutionPolicy Bypass -File G:\\dev\\v24\\JHP_AutoLoad\\SendEmail_PS.ps1");
JHP_DoNotOpenBPN();
}
}
break;
}
// case APINotify_Close:
// {
// break;
// }
// case APINotify_Quit:
// {
// break;
// }
//
default: break;
}
return err;
}
// -----------------------------------------------------------------------------
// ------------------------------ Class definition -----------------------------
JHP_AutoLoad_Dialog::JHP_AutoLoad_Dialog() :
DG::ModalDialog(ACAPI_GetOwnResModule(), 32500, ACAPI_GetOwnResModule()),
JHP_AUTOLOAD_BPN_Icon(GetReference(), JHP_AUTOLOAD_BPNID),
OK_Button(GetReference(), OkID)
{
AttachToAllItems(*this);
}
JHP_AutoLoad_Dialog::~JHP_AutoLoad_Dialog()
{
}
void JHP_AutoLoad_Dialog::ButtonClicked(const DG::ButtonClickEvent& ev)
{
if (ev.GetSource() == &OK_Button)
{
PostCloseRequest(Accept);
}
}
static GSErrCode __ACENV_CALL SelectionChangeHandler(const API_Neig* selElemNeig)
{
if (selElemNeig->neigID != APINeig_None) {
char msgStr[256];
sprintf(msgStr, "Last selected element: NeigID %d; guid: %s, inIndex: %d",
selElemNeig->neigID, (const char*)APIGuid2GSGuid(selElemNeig->guid).ToUniString().ToCStr(), selElemNeig->inIndex);
ACAPI_WriteReport(msgStr, false);
}
else {
ACAPI_WriteReport("All elements deselected", false);
}
JHP_DoNotOpenBPN();
return NoError;
}
// ------------------------------ Class definition -----------------------------
// =============================================================================
//
// Required functions
//
// =============================================================================
GSErrCode __ACENV_CALL MenuCommandHandler(const API_MenuParams* params)
{
return ACAPI_CallUndoableCommand("JHP_AutoLoad Menu Command", [&]() -> GSErrCode {
switch (params->menuItemRef.menuResID)
{
case JHP_AUTOLOAD_MENU_STRINGSID: {
//Execute Menu option code:
/* switch (params->menuItemRef.itemIndex)
{
//Execute Menu suboptions
} */
}
}
return NoError;
});
}
// MenuCommandHandler
//------------------------------------------------------
// Dependency definitions
//------------------------------------------------------
API_AddonType __ACENV_CALL CheckEnvironment(API_EnvirParams* envir)
{
RSGetIndString(&envir->addOnInfo.name, JHP_AUTOLOAD_ABOUT_STRINGSID, 1, ACAPI_GetOwnResModule());
RSGetIndString(&envir->addOnInfo.description, JHP_AUTOLOAD_ABOUT_STRINGSID, 2, ACAPI_GetOwnResModule());
//return APIAddon_Normal;
return APIAddon_Preload; // Change to APIAddon_Preload to allow listening for events!
}
// CheckEnvironment
//------------------------------------------------------
// Interface definitions
//------------------------------------------------------
GSErrCode __ACENV_CALL RegisterInterface(void)
{
GSErrCode err = NoError;
err = ACAPI_Register_Menu(JHP_AUTOLOAD_MENU_STRINGSID, 0, MenuCode_UserDef, MenuFlag_Default);
err = ACAPI_Register_SupportedService('JHPS', 1);
return NoError;
}
// RegisterInterface
// -----------------------------------------------------------------------------
// Initialize
// called after the Add-On has been loaded into memory
// -----------------------------------------------------------------------------
GSErrCode __ACENV_CALL Initialize(void)
{
//// look at send/receive data on teamwork projects
///////////
//
// Autoload stuff goes here.
//
///////////
GSErrCode err = ACAPI_Install_MenuHandler(JHP_AUTOLOAD_MENU_STRINGSID, MenuCommandHandler);
err = ACAPI_Notify_CatchProjectEvent(APINotify_Open, JHP_EventHandler);
err = ACAPI_Notify_CatchSelectionChange(SelectionChangeHandler);
///////////
//
// End of Autoload.
//
///////////
return err;
}
// Initialize
// -----------------------------------------------------------------------------
// FreeData
// called when the Add-On is going to be unloaded
// -----------------------------------------------------------------------------
GSErrCode __ACENV_CALL FreeData(void)
{
return NoError;
}
// FreeData
JHP_AutoLoad.hpp:
#pragma once
#ifndef JHP_AUTOLOAD_DIALOG_HPP
#define JHP_AUTOLOAD_DIALOG_HPP
#include "DGModule.hpp"
class JHP_AutoLoad_Dialog : public DG::ModalDialog,
public DG::CompoundItemObserver,
public DG::ButtonItemObserver
{
protected:
enum Controls {
JHP_AUTOLOAD_BPNID = 1,
OkID = 2
};
DG::IconItem JHP_AUTOLOAD_BPN_Icon;
DG::Button OK_Button;
virtual void ButtonClicked(const DG::ButtonClickEvent& ev) override;
public:
JHP_AutoLoad_Dialog();
~JHP_AutoLoad_Dialog();
};
#endif JHP_AUTOLOAD_DIALOG_HPP
JHP_AutoLoad.grc:
#include "JHP_AutoLoadResIDs.hpp"
'STR#' JHP_AUTOLOAD_ABOUT_STRINGSID "Add-on Name and Description" {
// /* [ 1] */ "JHP_AutoLoad"
// /* [ 2] */ "Do stuff automatically at ArchiCAD start OR File > New OR File > Open"
}
// /* Text appearing in the menu
// -- same as the name of the folder without underscore(s) */
// 'STR#' JHP_AUTOLOAD_MENU_STRINGSID "Strings for the Menu" {
// /* [ ] */ "JHP_AutoLoad"
// /* [ 1] */ "Do stuff automatically at ArchiCAD start OR File > New OR File > Open"
// }
/* Localizable dialog resource(s) with the accompanying help resource(s) */
'GDLG' 32500 Modal 0 0 884 1050 "JHP: ERROR - Do not open .bpn file" {
/* [ 1] */ Icon 0 25 884 946 JHP_AUTOLOAD_BPNID
/* [ 2] */ Button 407 991 70 43 LargePlain "OK"
}
'DLGH' 32500 DLG_32500_JHP_AUTOLOAD {
1 "JHP_AUTOLOAD_BPN" Icon_0
2 "JHP_OK" Button_0
}
2023-05-15 08:08 PM - edited 2023-05-15 08:09 PM
My current error message has new information and is now a bit more revealing with "Output directory does not end with a trailing slash..."
Build started...
1>------ Build started: Project: JHP_AutoLoad, Configuration: Release x64 ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(499,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
1>Compiling the localized GRC file...
1>JHP_AutoLoad.grc
1>
1>
1>G:Build\x64\Release\\RO\JHP_AutoLoad.grc.rc2.i (29) : Extra character on line (ResID: 32000)
1>
1>Write_Error: Extra character on line (ResID: 32000)
1>Compiling the RC2 file...
1>Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
1>
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>
1>RFIX.WIN\JHP_AutoLoad.rc2(11): fatal error RC1015: cannot open include file 'JHP_AutoLoad.grc.rc2'.
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom build for 'RINT\JHP_AutoLoad.grc;RFIX.WIN\JHP_AutoLoad.rc2' exited with code 1.
1>Done building project "JHP_AutoLoad.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
And, sure enough...
But adding the trailing slash generates the same error [1>G:Build\x64\Release\\RO\JHP_AutoLoad.grc.rc2.i (29) : Extra character on line (ResID: 32000)]
without the pushback of the trailing slash problem. Very counter-intuitive for me...
2023-05-16 07:57 AM
at first glance, on line 4 and 5 of your grc file items 1 and 2 are commented. Any reason for that ?
try removing the //
2023-05-17 11:36 PM
This is intentional.
The generic purpose of this Add-On is to automatically do stuff at model open. What I want to accomplish is over and done with before the user makes the first click in any and every model.
Specifically, I am implementing this to discourage our users from opening the .bpn version of the project they are working on. I am using APINotify_Open to install my custom event handler that senses that a .bpn file has been opened. Then using ACAPI_Notify_CatchSelectionChange to monitor and trigger, making it VERY difficult to work on with a constantly appearing dialog notification that they are in the wrong file.
This process does not need a selectable menu option. When I uncomment, I get the undesirable menu selection. Good eye, though...
Today, I have restarted this project from scratch instead of converting my working AC24 version for AC25. So far, so good...
Thanks so much for your interest in my dilemma.
- chris
2023-05-18 12:25 AM - edited 2023-05-18 12:27 AM
And now, all is in working order.
Thanks again @julienK.
Sometimes doing it is easier than tinkering with it...
When users open a .bpn file [in 24, and now in 25], they get...
an annoying notification at File > Open, at every selection, at every deselection, and at every zoom/pan while something is selected:
their own personal entry into the log file:
And... We get an email:
Hopefully, this gets the message across.
- chris
2023-05-19 02:41 AM
That's a really awesome idea for an addon!
I have junior staff accidently opening bpn's all the time, it drives me nuts, I would love to have something like this.