Hi,
I'm absolutely new to this, trying to learn.
I'm getting the above error when trying to create new command calling the createLine() function from the Object ARX help webpage. What am I doing wrong here?
This is how I'm creating new commands.
void initApp()
{
//Register a command with AutoCAD command mechanics.
acedRegCmds->addCommand(_T("HelloWorld_Commands"),
_T("Hello"),
_T("SayHello"),
ACRX_CMD_TRANSPARENT,
helloworld);
acedRegCmds->addCommand(_T("HelloWorld_Commands"),
_T("FAPLCreateLine"),
_T("FAPLCreateLine"),
ACRX_CMD_TRANSPARENT,
createLine);
}
This is the createLine( ) function from the help webpage.
AcDbObjectId createLine()
//void createLine()
{
AcGePoint3d startPt(4.0, 2.0, 0.0);
AcGePoint3d endPt(10.0, 7.0, 0.0);
AcDbLine *pLine = new AcDbLine(startPt, endPt);
AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,
AcDb::kForWrite);
pBlockTable->close();
AcDbObjectId lineId;
pBlockTableRecord->appendAcDbEntity(lineId, pLine);
pBlockTableRecord->close();
pLine->close();
return lineId;
}
Thanks in advance for any help!
Solved! Go to Solution.
Solved by Alexander.Rivilis. Go to Solution.
createLine have return nothing (e.g. void)
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Hi @Alexander.Rivilis ,
Thank you for the response.
I don't understand what you are trying to say. In the createLine function the LineID is being returned.
Or are you saying the addCommand is expecting a void function?
If that is the case, how to I add the command so that it can execute the createLine() function which is not a void function?
I did try converting the createLine() function to void function and removing the return line, but that doesn't work either. I think it has to be AcDbObjectId createLine().
Function that registered with acedRegCmds->addCommand may not return any value. This function has declaration such as:
void createLine(void);
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
That worked. I was able to compile and test the arx file.
Thank you!!
void createLine()
{
AcGePoint3d startPt(4.0, 2.0, 0.0);
AcGePoint3d endPt(10.0, 7.0, 0.0);
AcDbLine *pLine = new AcDbLine(startPt, endPt);
AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,
AcDb::kForWrite);
pBlockTable->close();
AcDbObjectId lineId;
pBlockTableRecord->appendAcDbEntity(lineId, pLine);
pBlockTableRecord->close();
pLine->close();
}
Can't find what you're looking for? Ask the community or share your knowledge.