Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ShricharanaB
327 Views, 4 Replies

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

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!

 

4 REPLIES 4
Message 2 of 5

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

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

 

Message 4 of 5

@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

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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report