Command in MDI mode

Command in MDI mode

Anonymous
Not applicable
536 Views
6 Replies
Message 1 of 7

Command in MDI mode

Anonymous
Not applicable
Hi,
How can I write an AutoCAD command which will open a drawing and add a
line to it and will close the drawing with saving the changes. Is there any
way tro do it?

Thanks
satya
0 Likes
537 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
extern "C" AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
{
switch (msg) {
case AcRx::kInitAppMsg:
acrxDynamicLinker->unlockApplication(pkt);
acrxDynamicLinker->registerAppMDIAware(pkt); // This line insert please.
initApp();
break;
case AcRx::kUnloadAppMsg:
unloadApp();
break;
}
return AcRx::kRetOK;
}


"satya" wrote in message
news:08B5573B49FDD12A780FA43B2BDE5AFE@in.WebX.maYIadrTaRb...
> Hi,
> How can I write an AutoCAD command which will open a drawing and add a
> line to it and will close the drawing with saving the changes. Is there
any
> way tro do it?
>
> Thanks
> satya
>
>
0 Likes
Message 3 of 7

Anonymous
Not applicable
extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
{
 switch (msg)
{
 case AcRx::kInitAppMsg:
 
acrxDynamicLinker->unlockApplication(pkt);
 
size=3>acrxDynamicLinker->registerAppMDIAware(pkt);
 
// This line insert please.
  initApp();
  break;
 case
AcRx::kUnloadAppMsg:
  unloadApp();
 
break;
 }
 return AcRx::kRetOK;
}

> Hi,
>
    How can I write an AutoCAD command which will open a drawing
and add a
> line to it and will close the drawing with saving the changes.
Is there any
> way tro do it?
>
> Thanks
>
satya
>
>
0 Likes
Message 4 of 7

Anonymous
Not applicable
My code contains that line and still the following
code does not work as expected.

The line does not get added to the new file but
instead it gets added to the already opened drawing where the command was
issued. Any suggestions?

 

 AcDbDatabase* pNewDb =
NULL;
 acdbHostApplicationServices()->workingDatabase()->wblock(pNewDb);
 pNewDb->saveAs("E:\\TEMP\\1.dwg");
 delete
pNewDb;


 IAcadApplication
app;
 IAcadDocuments docs;
 IAcadDocument doc;

 

 app.AttachDispatch(acedGetAcadWinApp()->GetIDispatch(TRUE));
 docs.AttachDispatch(app.GetDocuments());
 doc.AttachDispatch(docs.Open("E:\\TEMP\\1.dwg",
COleVariant((short) FALSE, VT_BOOL)));
 doc.Activate();

 

 acedCommand(RTSTR, "_LINE", RTSTR, "0,0,0", RTSTR, "10,10,0",
RTNONE);


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
{
 switch (msg)
{
 case AcRx::kInitAppMsg:
 
acrxDynamicLinker->unlockApplication(pkt);
 
size=3>acrxDynamicLinker->registerAppMDIAware(pkt);
 
// This line insert please.
  initApp();
 
break;
 case AcRx::kUnloadAppMsg:
  unloadApp();
 
break;
 }
 return AcRx::kRetOK;
}

> Hi,
>
    How can I write an AutoCAD command which will open a
drawing and add a
> line to it and will close the drawing with saving
the changes. Is there any
> way tro do it?
>
>
Thanks
> satya
>
>
0 Likes
Message 5 of 7

Anonymous
Not applicable
Hi. satya.

 

Can not know in detail about your program.
But,
there is contents that do not fit in form during code.

 

acedCommand(RTSTR, "_LINE", RTSTR, "0,0,0", RTSTR,
"10,10,0", RTSTR, "", RTNONE);

 

 

Is sorry because do not help.

Best Regards.

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

My code contains that line and still the
following code does not work as expected.

The line does not get added to the new file but
instead it gets added to the already opened drawing where the command was
issued. Any suggestions?

 

 AcDbDatabase* pNewDb =
NULL;
 acdbHostApplicationServices()->workingDatabase()->wblock(pNewDb);
 pNewDb->saveAs("E:\\TEMP\\1.dwg");
 delete
pNewDb;


 IAcadApplication
app;
 IAcadDocuments docs;
 IAcadDocument doc;

 

 app.AttachDispatch(acedGetAcadWinApp()->GetIDispatch(TRUE));
 docs.AttachDispatch(app.GetDocuments());
 doc.AttachDispatch(docs.Open("E:\\TEMP\\1.dwg",
COleVariant((short) FALSE, VT_BOOL)));
 doc.Activate();

 

 acedCommand(RTSTR, "_LINE", RTSTR, "0,0,0", RTSTR, "10,10,0",
RTNONE);


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
{
 switch (msg)
{
 case AcRx::kInitAppMsg:
 
acrxDynamicLinker->unlockApplication(pkt);
 
size=3>acrxDynamicLinker->registerAppMDIAware(pkt);
 
// This line insert please.
  initApp();
 
break;
 case AcRx::kUnloadAppMsg:
  unloadApp();
 
break;
 }
 return AcRx::kRetOK;
}

> Hi,
>
    How can I write an AutoCAD command which will open a
drawing and add a
> line to it and will close the drawing with saving
the changes. Is there any
> way tro do it?
>
>
Thanks
> satya
>
>
0 Likes
Message 6 of 7

Anonymous
Not applicable
satya,

You need a command running from the application context or call a function
from application context.
This will avoid the command to stop when the current document is changed due
a new file or an open file process.

Take a look at the following sample:

\ObjectARX 2002\samples\docman

(see acDocManager->executeInApplicationContext(); calls)

Also, be aware to treat zero document state as well.

Regards,
Fernando.

"satya" wrote in message
news:08B5573B49FDD12A780FA43B2BDE5AFE@in.WebX.maYIadrTaRb...
> Hi,
> How can I write an AutoCAD command which will open a drawing and add a
> line to it and will close the drawing with saving the changes. Is there
any
> way tro do it?
>
> Thanks
> satya
>
>
0 Likes
Message 7 of 7

Anonymous
Not applicable
WOW!!!!!!
It worked.
Thanks a TON.

"Fernando P. Malard" wrote in message
news:1492FAEDE8D4FBB81C3147653ED9C7DA@in.WebX.maYIadrTaRb...
> satya,
>
> You need a command running from the application context or call a function
> from application context.
> This will avoid the command to stop when the current document is changed
due
> a new file or an open file process.
>
> Take a look at the following sample:
>
> \ObjectARX 2002\samples\docman
>
> (see acDocManager->executeInApplicationContext(); calls)
>
> Also, be aware to treat zero document state as well.
>
> Regards,
> Fernando.
>
> "satya" wrote in message
> news:08B5573B49FDD12A780FA43B2BDE5AFE@in.WebX.maYIadrTaRb...
> > Hi,
> > How can I write an AutoCAD command which will open a drawing and add
a
> > line to it and will close the drawing with saving the changes. Is there
> any
> > way tro do it?
> >
> > Thanks
> > satya
> >
> >
>
>
0 Likes