如何读取DWG布局空间中的信息

原文发布时间:2013-08-14

作者:小新

AutoCAD中制图,通常在模型空间中按照1:1比例绘制图形,在布局空间中完成出图时的设置。关于布局空间的知识,相信各位做过生产的童鞋比我更熟悉,不清楚的话,在网上也可以搜到大量的信息,所以这里我也不多说了。

本文只是说明在FME中如何读取布局空间中的信息,有时候做DWG数据的转换,可能需要同时转换布局空间中的信息,就会显得非常有用。

1、读取

FME AutoCAD DWG读模块中,有一个参数叫做“Read Paper Space”,这个参数就是控制是否读取布局空间信息的。默认没有勾选,如果需要读取,则打开读模块的参数设置框进行设置。如下图所示:


这样FME的读模块就会把布局空间中的信息一并读取到工作空间中。

2、区分

如何区分模型空间和布局空间中的信息呢?

由格式参数autocad_space控制,该参数只有两个取值:model_spacepaper_space。模型空间的要素,该值为model_space,布局空间的要素,该值为paper_space。根据该参数则可以在工作空间中对要素进行区分。





  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Qt读取DWG文件的坐标信息,可以使用DWG阅读器库,例如ODA的Teigha库。以下是一些示例代码,演示如何使用Teigha库和Qt读取DWG文件的坐标信息: ```cpp #include <QtWidgets/QApplication> #include <QtWidgets/QMainWindow> #include <OdaCommon.h> #include <Gi/GiViewport.h> #include <Gi/GiGeometrySimplifier.h> #include <Gi/GiSubEntityTraits.h> #include <Gs/Gs.h> #include <Ge/GeMatrix3d.h> #include <RxVariantValue.h> #include <RxObjectImpl.h> #include <RxModule.h> class DwgViewer : public QMainWindow, public OdGiGeometrySimplifier { public: DwgViewer(QWidget *parent = 0) : QMainWindow(parent) { OdRxModulePtr pMod = ::odrxDynamicLinker()->loadModule(OdString("TD_Root")); if (pMod.isNull()) throw std::runtime_error("Cannot load Teigha module"); OdRxModulePtr pRenderMod = ::odrxDynamicLinker()->loadModule(OdString("TD_Gs")); if (pRenderMod.isNull()) throw std::runtime_error("Cannot load Teigha render module"); m_pGsDevice = OdGsDevicePtr(OdGsDevice::createObject(), OdRxObjectImpl<OdGsDevice>); m_pGsView = OdGsViewPtr(OdGsView::createObject(), OdRxObjectImpl<OdGsView>); m_pGsView->setViewport(m_pGsDevice->createViewport()); this->setCentralWidget(m_pGsView->viewport()->widget()); this->resize(800, 600); OdDbDatabasePtr pDb = OdDbDatabase::createObject(); if (pDb.isNull()) throw std::runtime_error("Cannot create database"); if (pDb->readDwgFile(OdString("<filepath>")) != eOk) throw std::runtime_error("Cannot read DWG file"); OdDbBlockTablePtr pBlockTable = pDb->getBlockTable(); if (!pBlockTable.isNull()) { OdDbBlockTableRecordPtr pRecord; if (pBlockTable->getAt(OdString("Model_Space"), pRecord) != eOk) throw std::runtime_error("Cannot get Model_Space"); OdDbBlockTableRecordIteratorPtr pIterator = pRecord->newIterator(); while (!pIterator->done()) { OdDbEntityPtr pEntity = pIterator->entity(); if (!pEntity.isNull()) { pEntity->subOpen(); pEntity->subWorldDraw(this); pEntity->subClose(); } pIterator->step(); } } m_pGsView->setViewportBorderWidth(0); m_pGsView->add(OdGsDevicePtr(m_pGsDevice)); m_pGsDevice->setBackgroundColor(ODRGB(255, 255, 255)); m_pGsView->invalidate(); m_pGsView->update(); } virtual void polylineOut(OdInt32 nbPoints, const OdGePoint3d* pVertexList) { // 处理每个多边形的坐标信息 for (int i = 0; i < nbPoints; ++i) { OdGePoint3d point = pVertexList[i]; // 处理坐标点,例如打印它们 qDebug() << point.x << point.y << point.z; } } private: OdGsDevicePtr m_pGsDevice; OdGsViewPtr m_pGsView; }; int main(int argc, char *argv[]) { QApplication a(argc, argv); try { DwgViewer viewer; viewer.show(); a.exec(); } catch (const std::exception& ex) { qDebug() << ex.what(); return 1; } return 0; } ``` 请注意,上面的示例代码仅演示了如何读取DWG文件的坐标信息,并打印出来。您可以根据您的实际需求,对代码进行更改和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值