sendStringToExecute

sendStringToExecute

Anonymous
Not applicable
1,080 Views
3 Replies
Message 1 of 4

sendStringToExecute

Anonymous
Not applicable
Hy.
I use "
acDocManager->sendStringToExecute(acDocManager->document(pDb),Str);

"
for insert a block in autocad.
Then after this istruction i want to explode this block.
But if i use sendStringToExecute another time, it doesn't work because the
command insert isn't finish.
Can you help me?
Thank'you
0 Likes
1,081 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Hi Moky,
After trying it myself a few times I decided it's better to implement the
command
in ObjectARX: you are in control and don't have to worry about sinchronizing
your program with
the command line.
So if I were you I'd implement the INSERT command in ARX - there are a few
examples available on the Autodesk Custom Channel:
http://pointa.autodesk.com/local/enu/portal/CustomChannel/kdn/catsearch.asp

alex
0 Likes
Message 3 of 4

Anonymous
Not applicable
Thank'you!
But i couldn't use command because i'm in a COleDropTarget class, and the
ads_command doesn't work.

"alex" ha scritto nel messaggio
news:[email protected]...
> Hi Moky,
> After trying it myself a few times I decided it's better to implement the
> command
> in ObjectARX: you are in control and don't have to worry about
sinchronizing
> your program with
> the command line.
> So if I were you I'd implement the INSERT command in ARX - there are a few
> examples available on the Autodesk Custom Channel:
>
http://pointa.autodesk.com/local/enu/portal/CustomChannel/kdn/catsearch.asp
>
> alex
>
>
0 Likes
Message 4 of 4

Anonymous
Not applicable
Hi Moky,
what i meant was somthg like this (after it you can explode the new insert):

BOOL InsertBlock(char* szname)
{

//the error checking is maybe a bit paranoid but it can't hurt

Acad::ErrorStatus es;
AcDbObjectId id;
AcDbBlockTable* pBlockTable;

//check if the block is in the database

acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable,
AcDb::kForRead);
if(pBlockTable->has(szname) != Adesk::kTrue)
{
acutPrintf("ERROR: block %s doesn't exist.", szname);
pBlockTable->close();
return FALSE;
}

//get record ID of block szname
es = pBlockTable->getAt(szname, id);
pBlockTable->close();
if (es != Acad::eOk)
{
acutPrintf("Error opening block");
return FALSE;
}

//you should check here for attributes and act accordingly
//for simplicity's sake we assume the block has no attributes

//set data (either ask user or if preset pass it to the func)
//for instance:
AcGePoint3d pt(0.0, 0.0, 0.0); //insert pt
double sclX=1.0, sclY=1.0, sclZ=1.0;//block scale
double rot=0.0; //rotation angle
AcGeScale3d scale(sclX, sclY, sclZ);

//---allocate a block reference object

AcDbBlockReference *pBlkRef = new AcDbBlockReference;
if (pBlkRef == NULL)
{
acutPrintf("alloc error ");
return FALSE;
}

//---set up the block reference to the block definition ID and set
properties
es = pBlkRef->setBlockTableRecord(id);
if (es != Acad::eOk)
{
delete pBlkRef;
return FALSE;
}
es = pBlkRef->setPosition(pt);
if (es != Acad::eOk)
{
delete pBlkRef;
return FALSE;
}
es = pBlkRef->setRotation(rot);
if (es != Acad::eOk)
{
delete pBlkRef;
return FALSE;
}
es = pBlkRef->setScaleFactors(scale);
if (es != Acad::eOk)
{
delete pBlkRef;
return FALSE;
}

//---open current database's Model Space blockTableRecord
es =
acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable,
AcDb::kForRead);
if (es != Acad::eOk)
{
delete pBlkRef;
return FALSE;
}
AcDbBlockTableRecord *pBlockTableRecord;
es = pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,
AcDb::kForWrite);
if (es != Acad::eOk)
{
delete pBlkRef;
pBlockTable->close();
return FALSE;
}
pBlockTable->close();

//---append the block reference to the model space block table record
AcDbObjectId newEntId;
es = pBlockTableRecord->appendAcDbEntity(newEntId, pBlkRef);
//subsequently you can use the new newEntId to explode it
pBlockTableRecord->close();
if (es != Acad::eOk)
{
delete pBlkRef;
acutPrintf"The insert operation failed.");
return FALSE;
}
pBlkRef->close();
return TRUE;
}
0 Likes