Jump to content

Create a TCHAR in autoit.


Shane0000
 Share

Recommended Posts

Im trying to use ObjectArx (Autocad) to set some data.

Problem is plain text is not recognized. Further reading shows that I need to pass a TCHAR [wchar_t] (unicode format).

WOuld I do this using:

DllCall ( "dll", "return type", "function" [, type1, param1 [, type n, param n]] )

Maybe DllCall(???,'wstr','text to be converted')

Edited by Shane0000
Link to comment
Share on other sites

Thanks, but what goes in the ??? area? what DLL do I need to call to simply create a wchar_t that I can later pass to AutoCad

DllCall(???,'wstr','text to be converted')

If thats the wrong approach I also found 'DllStructCreate("WCHAR")' but I wouldnt know how to then get text inside that pointer

thanks for the help, Im a complete noob when it comes to c++ type stuff

Also how would i convert from wchar back to plain text

Edited by Shane0000
Link to comment
Share on other sites

Below is as far as I got.

I think I did your step 1, step 2 & 3 make no sense to me, could I trouble you for an example.

Thanks

Local Const $iSize0 = StringLen('Key') + 1
Local Const $iSize1 = StringLen('value') + 1
Local Const $tTemp3 = DllStructCreate("wchar[" & $iSize0 & "]") ;your step 1 i believe
Local Const $tTemp4 = DllStructCreate("wchar[" & $iSize1 & "]")
DllStructSetData($tTemp3, 1, "Key")
DllStructSetData($tTemp4, 1, "Value")
msgbox(0,"test",DllStructGetData ($tTemp4, 1))
Link to comment
Share on other sites

Below in lower code area is the details of the method I am trying to use. Calls to other methods return fine so Im sure the only thing can be properly defining the variables.

MY current call to the method:

Local Const $iSize0 = StringLen('Key') + 1
Local Const $iSize1 = StringLen('value') + 1
Local Const $tTemp3 = DllStructCreate("wchar[" & $iSize0 & "]")
Local Const $tTemp4 = DllStructCreate("wchar[" & $iSize1 & "]")
DllStructSetData($tTemp3, 1, "Key")
DllStructSetData($tTemp4, 1, "Value")
;my call to this method
$oAcadActDoc.SummaryInfo.addCustomSummaryInfo($tTemp3,$tTemp4)

If i could figure out 1 i can modify the example and fix the rest of my program.

Most of what I can find on AChar says that it is equivalent to TChar.

Most of the conversion from plain text to a unicode text done in VB is simply converting the text to TChar and this acceptable for the ACHAR (for autocad)

[ex. acutPrintf (_T("nNew Entity not Write")) ]

where '_T()' converts the text to an AutoCad friendly version.

Also this example: where ACHAR is assigned a TCHAR through _T()

ACHAR* szName = _T("MyTest");

Thanks for the help

AcDbDatabaseSummaryInfo::addCustomSummaryInfo
Collapse AllC++
virtual Acad::ErrorStatus addCustomSummaryInfo(
const ACHAR* key,
const ACHAR* value
) = 0;
Parameters
Parameters Description
const ACHAR* key Input key or name of the custom field to add to the list of custom fields
const ACHAR* value Input value or contents of the custom field
Description
This method should add a new custom field at the end of the existing list of custom fields.
Returns Acad::eOk if successful.
Edited by Shane0000
Link to comment
Share on other sites

Im using active x, but I have to have a Tchar Var to get and send some types of data to the target app (AutoCad)

other methods return successfully

$oAcad = ObjGet("","AutoCAD.Application")
$oAcadActDoc = $oAcad.activedocument                  ;returns correctly, able to query this object even
$oAcadActDoc.SummaryInfo.NumCustomInfo          ;returns correctly

$oAcadActDoc.SummaryInfo.addCustomSummaryInfo($tTemp3,$tTemp4) ;does not work, Target app expects Tchar Vars
Link to comment
Share on other sites

Not sure what this error is telling me,

$oAcadActDoc.SummaryInfo.addCustomSummaryInfo($tTemp3,$tTemp4)

And thats where I get the COM error 80020006, description 'UNKNOW NAME.'.

Ive checked that the method name is correct so I feel like its the variables.

Ive looked it (the error code 80020006) up in google and havent found much excluding Visual Fox Pro, says this error happens when ActiveX’s property or method name is mis-typed. And I think thats refering to the fact that variable types dont match when trying to interact with the method. But I dont know if that error is relevant to this error im getting.

This is the full text from the com error handler:

err.description is:

err.windescription is: 80020006

err.lastdllerror is: 0

err.scriptline is: 15

err.source is:

err.helpfile is:

err.helpcontext is: 13071088
Edited by Shane0000
Link to comment
Share on other sites

And about AutoIt auto formatting the var types,

There is a another similar method where I provide it an integer and it returns 2 pieces of text 'tKey' & 'tValue'.

getCustomSummaryInfo($i,$tKey,$tValue)

If autoit auto formats the vars, id think that this method would work as the target app would be suppling the data, I just need to give the target app valid containers to put the data in, which autoit should have done. This method gives the same 80020006 error also

Edited by Shane0000
Link to comment
Share on other sites

Ahh that would explain it i guess.

I ve got a 3k line app i did that worked fine until autocads move to T and A chars ....

I guess Ill have to do a multi language work around between Autoit and LiSP, but there's still no good way to transfer data between the 2 ....

Bummer, thanks for all the info and help

Edited by Shane0000
Link to comment
Share on other sites

This Achar is app specific to AutoCad and is assigned a Tchar (ACHAR* szName = _T("MyTest") )

All the ObjectArx -> AutoCad examples I find all pass Tchars.

From what Ive come across through google recently was that (my understanding) that Char is ansi, t/w/aChar are unicode (Not sure of what unicode even is for that matter).

And this is all new to me so I have no idea what the differences are between t w and a.

I think Im going to actually break down and take some programming classes. Perhaps I'll be able to revisit this latter in VB or C++

Anywho, have a good weekend!

Edited by Shane0000
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...