ObjectARX

Reply
Member
Posts: 4
Registered: ‎10-18-2009
Message 1 of 3 (617 Views)

AcDbPlotSettings paper image origin?

617 Views, 2 Replies
06-26-2011 05:02 PM

How do you access AcDbPlotSettings paper image origin from ARX?

AcDbPlotSettings
PaperImageOrigin
dxf code 148,149 x,y

http://docs.autodesk.com/ACD/2011/ENU/filesDXF/WS1a9193826455f5ff18cb41610ec0a2e719-7996.htm

 

Thanks,

John

ADN Support Specialist
Posts: 349
Registered: ‎05-22-2006
Message 2 of 3 (608 Views)

Re: AcDbPlotSettings paper image origin?

06-27-2011 11:57 AM in reply to: john_g1

Hi John,

 

To retrieve the origin, you can use AcDbPlotSettings::getPlotOrigin().

 

Plot settings are applied using the AcDbPlotSettingsValidator class. That is where you'll find the set functions corresponding to the get functions you see in AcDbPlotSettings. I've copied below a pertinent example from the ADN website (apologies for the sub-optimal formatting due to copy and paste).

 

Cheers,

 

Stephen Preston

Autodesk Developer Network

 

>>>

Issue

I want to Window plot a drawing to DWF, I'm using COM to plot the DWF but how do I setup the Plot Settings so that it plots using a couple of Window coordinates?

Solution

In ObjectARX you need to use the AcDbPlotSettingsValidator class to setup the Plot. Here is some code which shows you what to do. Note this is using the Window coordinates as the extents of the drawing. This is purely for test purposes - if you want to plot the extents then use setPlotType (pLayout, AcDbPlotSettings::kExtents). There is also a Visual LISP example following the ObjectARX code.

 


#import "acad.tlb" no_namespace

 

static void ASDKTS66871_PlotWindow_COM_testPlot(void)
 {
  // Use ActiveX interface to get the application object
  IAcadApplicationPtr pAcad = acedGetAcadWinApp()->GetIDispatch(TRUE);

  //get the path to plotter configuration
  _bstr_t szPrinterPath;
  szPrinterPath = pAcad->Preferences->GetFiles()->GetPrinterConfigPath() + _bstr_t("\\DWF6 ePlot.pc3");
  // get the current database
  AcDbDatabase *curDocDB = acdbHostApplicationServices()->workingDatabase();
  // get a pointer to the layout manager
  AcApLayoutManager *pLayoutManager = (AcApLayoutManager *)acdbHostApplicationServices()->layoutManager();
  const ACHAR *layoutName = pLayoutManager->findActiveLayout (true);
  // get the current layout
  AcDbLayout *pLayout = pLayoutManager->findLayoutNamed (layoutName, true); 
  // if we got it ok
  if (pLayout != NULL)
  {
   Acad::ErrorStatus es;
   // get the plotsetttings class
   AcDbPlotSettingsValidator *pPlotSettingsValidator = acdbHostApplicationServices()->plotSettingsValidator();
   // if we got it ok
   if (pPlotSettingsValidator != NULL)
   {
    // Refresh the layout lists in order to use it
    pPlotSettingsValidator->refreshLists (pLayout);
    // change the current layout plotter
    es = pPlotSettingsValidator->setPlotCfgName (pLayout, szPrinterPath);  
    // set the window to plot as the extents of the drawing
    es = pPlotSettingsValidator->setPlotWindowArea (pLayout,
     curDocDB->extmin ().x,
     curDocDB->extmin ().y,
     curDocDB->extmax ().x,
     curDocDB->extmax ().y);
    // set the orgin
    es = pPlotSettingsValidator->setPlotOrigin (pLayout,
     curDocDB->extmin ().x,
     curDocDB->extmin ().y);
    // set to plot centred
    es = pPlotSettingsValidator->setPlotCentered (pLayout, true);
    // setup the plot type to window
    es = pPlotSettingsValidator->setPlotType (pLayout, AcDbPlotSettings::kWindow);
    // set the scale
    es = pPlotSettingsValidator->setStdScaleType (pLayout, AcDbPlotSettings::smileyfrustrated:tdScaleType::kScaleToFit);

    // we have to close the layout here because the last parameter of
    // findLayoutNamed is true, leave layout open
    pLayout->close ();
   } 
  }

  // get the current document
  IAcadDocumentPtr pDoc = pAcad->GetActiveDocument();
  // create a plot object
  IAcadPlotPtr pPlot = pDoc->GetPlot();
  // lets plot
  pPlot->PlotToFile("c:\\test.dwf", szPrinterPath);
 }

 

Note: You do not need to use COM to plot. Instead you can use ObjectARX functions. A sample ships with the SDK. ( ..\ObjectARX 2009\samples\editor\AsdkPlotAPI )

 Here is a Visual LISP example:

(defun c:testPlotWindow ( / acadObject acadDocument activeLayoutObject plt p1 point1
     pPt1 pPt1sa pt1 p2 point2 pPt2 pPt2sa pt2 )
  (vl-load-com)
  (setq acadObject (vlax-get-Acad-object))
  (setq acadDocument (vla-get-ActiveDocument acadObject))
  (setq activeLayoutObject (vla-Get-ActiveLayout acadDocument))

  (setq plt (vla-get-plot acadDocument))

  (vla-put-configname activeLayoutObject "DWF6 ePlot.pc3")
  (vla-put-canonicalmedianame
    activeLayoutObject
    "ISO_full_bleed_A3_(420.00_x_297.00_MM)"
    )
  (vla-put-paperunits activeLayoutObject acMillimeters)
  (vla-put-plotrotation activeLayoutObject ac0degrees)
  ; How to control the Plot Style Table
  ; (vla-put-StyleSheet activeLayoutObject "HP LaserJet 4MV.ctb")

  (setq p1 (getpoint "\nSelect Window Point No 1 (Lower Left): "))
  (setq point1 (list (car p1) (cadr p1)))
  (setq pPt1 (vlax-make-safearray vlax-vbDouble '(0 . 1)))
  (setq pPt1sa (vlax-safearray-fill pPt1 point1))
  (setq pt1 (vlax-make-variant
       pPt1sa
       (logior vlax-vbarray vlax-vbDouble)
       )
 )

  (setq p2 (getpoint "\nSelect Window Point No 2 (Upper Right): "))
  (setq point2 (list (car p2) (cadr p2)))
  (setq pPt2 (vlax-make-safearray vlax-vbDouble '(0 . 1)))
  (setq pPt2sa (vlax-safearray-fill pPt2 point2))
  (setq pt2 (vlax-make-variant
       pPt2sa
       (logior vlax-vbarray vlax-vbDouble)
       )
 )

  (vla-SetWindowToPlot activeLayoutObject pt1 pt2)
  (vla-put-plottype activeLayoutObject acWindow)

   (vla-plottofile plt "c:\\test.dwf" "DWF6 ePlot.pc3")

  )

Cheers,

Stephen Preston
Autodesk Developer Network
Member
Posts: 4
Registered: ‎10-18-2009
Message 3 of 3 (605 Views)

Re: AcDbPlotSettings paper image origin?

06-27-2011 12:26 PM in reply to: StephenPreston

I'm looking for "paper image origin" not the "plot origin".

 

getPlotOrigin() retrieve values for DXF code 46,47

 

I need the values for DXF code 148,149.

 

http://docs.autodesk.com/ACD/2011/ENU/filesDXF/WS1a9193826455f5ff18cb41610ec0a2e719-7996.htm

 

 

Thanks,

 

John

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community