How to invoke AutoCad's Print function in arx?

How to invoke AutoCad's Print function in arx?

Anonymous
Not applicable
806 Views
5 Replies
Message 1 of 6

How to invoke AutoCad's Print function in arx?

Anonymous
Not applicable
Hi,all:

I met some trouble.

I want to print what I draw in AutoCad,How to realize it in ARX?
0 Likes
807 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
I appreciate what you can offer

Best regards

Mayi
0 Likes
Message 3 of 6

Anonymous
Not applicable
Hello Mayi,

On Wed, 1 Jun 2005 04:16:45 +0000, Mayi wrote:

> I want to print what I draw in AutoCad,How to realize it in ARX?

If you are using AutoCAD before version 2005 then you need to use
ActiveX/COM. There is a sample on how to use ActiveX/COM at:
docsamps\comsamps (depending on if you are using MFC or not.)

The ActiveX class for plotting is AcadPlot. You will have to look in the
VBA documentation for information on how to use it. To set plotting params
you will need to use AcDbPlotSettingsValidator, AcApLayoutManager

In 2005 there is an ObjectArx Classes for printing. There is a sample in
2005 at: samples\editor\AsdkPlotAPI


// Anders
0 Likes
Message 4 of 6

Anonymous
Not applicable
Hi,Anders Eriksson:

Thank you very much, your help is of great help to me.

But I am shamed to say that I know little about ActiveX and COM.

Follow your instruction , I found there are three folders in
docsamps\comsamps :
AsdkMfcComSamp,AsdkPlainComSamp,AsdkSquareWrapper

My ARX Project is based on MFC (VC 6.0),Which folder should I look into
first?

and also I want to know where can I get ActiveX class:AcadPlot

and which funtions should I invoke from AcDbPlotSettingsValidator and
AcApLayoutManager to realize requirement of printing?

I am sorry that my question may bring you some trouble and waste your
time,but hopefully,may you help me once again?

I do appreciate your help

Best regards

Mayi
0 Likes
Message 5 of 6

Anonymous
Not applicable
Hello Mayi,

On Wed, 1 Jun 2005 08:29:40 +0000, Mayi wrote:

> But I am shamed to say that I know little about ActiveX and COM.
>
There is nothing to be a shamed for!

> Follow your instruction , I found there are three folders in
> docsamps\comsamps :
> AsdkMfcComSamp,AsdkPlainComSamp,AsdkSquareWrapper
>
> My ARX Project is based on MFC (VC 6.0),Which folder should I look into
> first?
>
The AsdkMfcComSamp is based on MFC so that will be a start.
> and also I want to know where can I get ActiveX class:AcadPlot

I knew that I formulated that part badly! (English isn't my first language)
AcadPlot is an ActiveX Class (Look in the VBA help in the AutoCAD\Help
directory) There are two ways to use ActiveX in VC++/MFC. One is to use the
ClassWizard and Add Class and select acad.tlb[1]. Now the ClassWizard will
create a class, or more correctly a number of classes, for you to use to
access AutoCAD via ActiveX/COM One of the classes may be named IAcadPlot

The other way, which 'most' people recommend, is to #import "acad.tlb". A
introductory article on how to use this can you find here:
http://www.codeproject.com/database/WittmerADO.asp
This is about ADO[2] but it will teach the basic things.
The classes you will need to use are:
IAcadApplicationPtr
IAcadDocumentPtr
IAcadPlotPtr


The AsdkMfcComSamp is using ClassWizard!


> and which funtions should I invoke from AcDbPlotSettingsValidator and
> AcApLayoutManager to realize requirement of printing?
>
That depends on what you want to do 😉

To get the current layout:
AcApLayoutManager *pLayoutManager = (AcApLayoutManager*)
acdbHostApplicationServices()->layoutManager();
const char *layoutName = pLayoutManager->findActiveLayout (true);
// get the current layout
AcDbLayout *pLayout = pLayoutManager->findLayoutNamed (layoutName, true);

To initialize AcDbPlotSettingsValidator you need to do this:
// get the plotsetttings class
AcDbPlotSettingsValidator *pPlotSettingsValidator =
acdbHostApplicationServices()->plotSettingsValidator();

// Refresh the layout lists in order to use it
pPlotSettingsValidator->refreshLists (pLayout);
// change the current layout plotter
es = pPlotSettingsValidator->setPlotCfgName (pLayout, szPrinterPath);
// set style table
es = pPlotSettingsValidator->setCurrentStyleSheet(pLayout,szStylePath);
// setup the plot type to window
es = pPlotSettingsValidator->setPlotType (pLayout,
AcDbPlotSettings::kExtents);
// set the scale
es = pPlotSettingsValidator->setStdScaleType (pLayout,
AcDbPlotSettings::StdScaleType::kScaleToFit);
// we have to close the layout here because the last parameter of
// findLayoutNamed is true, leave layout open
pLayout->close ();


> I am sorry that my question may bring you some trouble and waste your
> time,but hopefully,may you help me once again?
>
No problem! I hope that you can figure out something using the info I have
given you. If not ask again!!

If times permit I will create a sample application for plotting from
ObjectArx. (This will not happen before the weekend)

Best wishes

// Anders
0 Likes
Message 6 of 6

Anonymous
Not applicable
Hi,Anders Eriksson:

I am very glad to see your reply,It is very kind of you 🙂
I do appreciate what you have done for me,I do !!!

And I do wish you are happy and enjoying colorful life every day.

And A beautiful wish to you and your family --- live a happy life and
everything goes well.

Sincerely
Mayi
0 Likes