天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 55|回复: 0

使用 ObjectARX COM 和 LISP 将窗口绘制到 DWF

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
‎使用 ObjectARX COM 和 LISP 将窗口绘制到 DWF‎

‎问题‎
‎我想将绘图窗口绘制到 DWF,我使用 COM 绘制 DWF,但如何设置"打印设置",以便它使用几个窗口坐标进行绘图?‎

‎在 ObjectARX 中,您需要使用 AcDbPlotSettingsValidator 类来设置 Plot。下面是一些代码,可以告诉您该怎么做。请注意,这是使用窗口坐标作为绘图的范围。这纯粹是为了测试目的 - 如果要绘制范围,请使用 setPlotType (pLayout, AcDbPlotSettings::kExtents)。在 ObjectARX 代码之后还有一个 Visual LISP 示例。‎
[code]#import "acax19ENU.tlb" no_namespace

#include "acaplmgr.h"

static void ASDKTS66871_PlotWindow_COM_testPlot(void)

{

  // Use ActiveX interface to get the application object

  IAcadApplicationPtr pAcad = acedGetAcadWinApp()->GetIDispatch(FALSE);



  //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::StdScaleType::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 necessarily need to use COM to plot. Instead you can use ObjectARX functions. A good sample ships with the ObjectARX 2009 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")

  )[/code]

 

 

 

 

使用 ObjectARX COM 和 LISP 将窗口绘制到 DWF
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 13:37 , Processed in 0.126467 second(s), 25 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表