AcDbObjectId (*)()" is incompatible with parameter of type "AcRxFunctionPtr"

AcDbObjectId (*)()" is incompatible with parameter of type "AcRxFunctionPtr"

ShricharanaB
Advocate Advocate
1,159 Views
4 Replies
Message 1 of 5

AcDbObjectId (*)()" is incompatible with parameter of type "AcRxFunctionPtr"

ShricharanaB
Advocate
Advocate

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!

 

0 Likes
Accepted solutions (1)
1,160 Views
4 Replies
Replies (4)
Message 2 of 5

Alexander.Rivilis
Mentor
Mentor

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
Expert Elite Member

Message 3 of 5

ShricharanaB
Advocate
Advocate

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(). 

 

0 Likes
Message 4 of 5

Alexander.Rivilis
Mentor
Mentor
Accepted solution

@ShricharanaB 

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
Expert Elite Member

Message 5 of 5

ShricharanaB
Advocate
Advocate

Hi, @Alexander.Rivilis 

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();
	
}

 

0 Likes