einvalidInput while invoking Application.Invoke(rb)

einvalidInput while invoking Application.Invoke(rb)

Anonymous
Not applicable
1,291 Views
2 Replies
Message 1 of 3

einvalidInput while invoking Application.Invoke(rb)

Anonymous
Not applicable

Hi All,

In an ARX file we have the below code :

 

int upd_text(void)
{
acutPrintf(L"\nInside upd_text.\n");
ads_name ENT;
struct resbuf *RB, *ARGS;
// RB = ads_newrb(RTSTR);
RB = acutNewRb(RTSTR);
// ARGS = ads_getargs();
ARGS = acedGetArgs();
if (ARGS) {
ENT[0] = ARGS->resval.rlname[0];
ENT[1] = ARGS->resval.rlname[1];
} else {
// if ((RESULT = ads_entlast(ENT)) != RTNORM) {
if ((RESULT = acdbEntLast(ENT)) != RTNORM) {
// ads_printf(L"\nCannot find entity in drawing database.\n");
acutPrintf(L"\nCannot find entity in drawing database.\n");
return RESULT;
}
}
// if ((RESULT = ads_getvar(L"CECOLOR",RB)) != RTNORM) {
if ((RESULT = acedGetVar(L"CECOLOR",RB)) != RTNORM) {
// ads_printf(L"\nCannot get current color.\n");
acutPrintf(L"\nCannot get current color.\n");
return RESULT;
}
if ((!wcscmp(RB->resval.rstring, L"1")) ||
(!wcscmp(RB->resval.rstring, L"2")) ||
(!wcscmp(RB->resval.rstring, L"3"))) {
upd_color(ENT,-1,0, L"BAY", L"*");
upd_color(ENT,-1,0, L"GRP_CODE", L"*");
}
// ads_relrb(RB);
acutRelRb(RB);
// ads_retvoid();
acedRetVoid();
return RTNORM;
}

 

From VB.NET we are invoking it as below :

 

 

Public Shared Function upd_text(objID As ObjectId) As Integer
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Using dl As DocumentLock = doc.LockDocument()
Using rb As New ResultBuffer()
rb.Add(New TypedValue(CInt(LispDataType.Text), "upd_text"))
rb.Add(New TypedValue(CInt(LispDataType.ObjectId), objID))
Dim rbRes As ResultBuffer = Application.Invoke(rb)
End Using
End Using
 
End Function

 

We are getting the below error :
Autodesk.AutoCAD.Runtime.Exception: eInvalidInput
at Autodesk.AutoCAD.ApplicationServices.Core.Application.Invoke(ResultBuffer args)
at GSITE_NIMCAD.ARXWRAPPER.upd_text(ObjectId objID) in D:\Application Data\GSITE\Working 2017 Migration\GSITE_NIMCAD\ACAD_Mgr\ARXWRAPPER.vb:line 393
at GSITE_NIMCAD.GSITE_NIMCAD.Draft.add_blck(String bdir, String blk, Double rot, Double sc, Point3d insPoint) in D:\Application Data\GSITE\Working 2017 Migration\GSITE_NIMCAD\Draft\Draft.vb:line 1570
at GSITE_NIMCAD.GSITE_NIMCAD.Nimcad.mnuAddSym(ResultBuffer args) in D:\Application Data\GSITE\Working 2017 Migration\GSITE_NIMCAD\Nimcad.vb:line 2617
at GSITE_NIMCAD.GSITE_NIMCAD.NIMCAD_Commands.CMD_Lu_FloPlaInfoReCir() in D:\Application Data\GSITE\Working 2017 Migration\GSITE_NIMCAD\Commands\NIMCAD_Commands.vb:line 955
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()

Could anybody explain why is this. It is working fine in AutoCad 2014. We are now upgrading it to AutoCad 2018.

 

Also We have another code : 

 

 Dim cmdTTEXT As String = "(TTEXT " + scal + " )" + vbCr   '(TTEXT scal)
                Application.DocumentManager.MdiActiveDocument.SendStringToExecute(cmdTTEXT, True, False, False) '(command "dtext")

Here we are getting 

 

error: no function definition: TTEXT

 

Is TTEXT deprecated. If so which function should we use. Please guide.

 

Thanks in Advance

0 Likes
Accepted solutions (1)
1,292 Views
2 Replies
Replies (2)
Message 2 of 3

ActivistInvestor
Mentor
Mentor
Accepted solution

You don't pass the name of the C++ function to Invoke(), you pass the name that you used with acedDefun() to register the C++ function as callable from LISP or acedInvoke() or Application.Invoke().

 

That's assuming of course, that you used acedDefun() (or the ObjectARX wizard) to register the function in the first place.  Did you?

Message 3 of 3

Anonymous
Not applicable

Hi,

 

Yes we are doing that in arxentrypoint.cpp file as shown below : 

static func_entry func_table[] = {
	{ L"blupdate",blupdate },{ L"partialupdate",partialupdate },
	{ L"upd_text",upd_text },{ L"check_ver",check_ver },
	{ L"upd1_2",upd1_2 },{ L"move_sheet",move_sheet },{ L"insert_sk",insert_sk }
	
};

static int funcload()
{
	short i = sizeof(func_table) / sizeof(func_entry);
	while (i--) {
		if (!acedDefun(func_table[i].func_name, i))
			return RTERROR;
	}
	return RTNORM;
}

 

funcload() was not called in On_kLoadDwgMsg that was the problem. Now it is working fine.

 

Thank you very much 🙂

0 Likes