设为首页收藏本站

中国膜结构网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

膜结构车棚
膜结构车棚膜结构资质国产膜材 膜结构网中国膜结构协会
查看: 151|回复: 0

收藏的CAD扩展工具的源码1

[复制链接]
  • TA的每日心情
    开心
    2021-6-23 14:19
  • 签到天数: 1543 天

    [LV.Master]伴坛终老

    发表于 2020-12-29 14:05 | 显示全部楼层 |阅读模式
    1. 收藏的CAD扩展工具的源码:



    2. Acad::ErrorStatus CDrawFunction::getAllEntity(AcDbDatabase *pDb,AcDbObjectIdArray& IdArr,
    3. const AcArray& layerNameArr)
    4. {
    5. Acad::ErrorStatus es=Acad::eOk;
    6. ASSERT(pDb);
    7. if(pDb==NULL)
    8. return Acad::eInalidInput;
    9. AcDbBlockTable *pBlkTable=NULL;
    10. if((es=pDb->getBlockTable(pBlkTable,AcDb::kForRead))!=Acad::eOk)//打开块表
    11. {
    12. acedAlert("打开块表失败");
    13. return es;
    14. }
    15. AcDbBlockTableRecord *pBlkTableRecord=NULL;
    16. if((es=pBlkTable->getAt(ACDB_MODEL_SPACE,pBlkTableRecord,AcDb::kForRead))!=Acad::eOk)//打开块表记录
    17. {
    18. acedAlert("打开块表记录失败");
    19. pBlkTable->close();
    20. return es;
    21. }
    22. pBlkTable->close();//关闭块表

    23. AcDbBlockTableRecordIterator *pIterator=NULL; //创建叠代器
    24. if((es=pBlkTableRecord->newIterator(pIterator))!=Acad::eOk)
    25. {
    26. pBlkTableRecord->close();
    27. return es;
    28. }

    29. CAcModuleResourceOerride resoerride;
    30. CProgressDlg progress;
    31. progress.Create();
    32. progress.SetPos(0);
    33. progress.SetWindowText("正在检测图形中所有实体...");

    34. for(pIterator->start();!pIterator->done();pIterator->step())//遍历整个数据库
    35. {
    36. AcDbEntity *entity=NULL;
    37. es=pIterator->getEntity(entity,AcDb::kForRead); //打开实体

    38. if(es==Acad::eLockiolation)
    39. {
    40. acedAlert("内存锁定");
    41. }
    42. else if(es==Acad::eWasOpenForWrite)
    43. {
    44. acedAlert("实体以写方式打开");
    45. }
    46. else if(es==Acad::eWasOpenForRead)
    47. {
    48. acedAlert("实体以读方式打开");
    49. }
    50. else
    51. {
    52. if(layerNameArr.contains(entity->layer()))
    53. IdArr.append(entity->objectId());
    54. entity->close();
    55. }
    56. progress.StepIt();
    57. }
    58. delete pIterator;pIterator=NULL;
    59. pBlkTableRecord->close();
    60. acutPrintf("eend");
    61. return es;
    62. }

    63. //得到指定层上指定颜色的所有实体
    64. Acad::ErrorStatus CDrawFunction::getAllEntity(AcDbDatabase *pDb,AcDbObjectIdArray& IdArr,
    65. const AcArray& layerNameArr,Adesk::UInt16 colorIndex)
    66. {
    67. Acad::ErrorStatus es=Acad::eOk;
    68. ASSERT(pDb);
    69. if(pDb==NULL)
    70. return Acad::eInalidInput;
    71. AcDbBlockTable *pBlkTable=NULL;
    72. if((es=pDb->getBlockTable(pBlkTable,AcDb::kForRead))!=Acad::eOk)//打开块表
    73. {
    74. acedAlert("打开块表失败");
    75. return es;
    76. }
    77. AcDbBlockTableRecord *pBlkTableRecord=NULL;
    78. if((es=pBlkTable->getAt(ACDB_MODEL_SPACE,pBlkTableRecord,AcDb::kForRead))!=Acad::eOk)//打开块表记录
    79. {
    80. acedAlert("打开块表记录失败");
    81. pBlkTable->close();
    82. return es;
    83. }
    84. pBlkTable->close();//关闭块表

    85. AcDbBlockTableRecordIterator *pIterator=NULL; //创建叠代器
    86. if((es=pBlkTableRecord->newIterator(pIterator))!=Acad::eOk)
    87. {
    88. pBlkTableRecord->close();
    89. return es;
    90. }

    91. CAcModuleResourceOerride resoerride;
    92. CProgressDlg progress;
    93. progress.Create();
    94. progress.SetPos(0);
    95. progress.SetWindowText("正在检测图形中所有实体...");

    96. for(pIterator->start();!pIterator->done();pIterator->step())//遍历整个数据库
    97. {
    98. AcDbEntity *entity=NULL;
    99. if((es=pIterator->getEntity(entity,AcDb::kForRead))!=Acad::eOk)//打开实体
    100. {
    101. delete pIterator;pIterator=NULL;
    102. pBlkTableRecord->close();
    103. return es;
    104. }
    105. if(layerNameArr.contains(entity->layer())&&entity->colorIndex()==colorIndex)
    106. IdArr.append(entity->objectId());
    107. entity->close();
    108. progress.StepIt();
    109. }
    110. delete pIterator;pIterator=NULL;
    111. pBlkTableRecord->close();
    112. return es;
    113. }

    114. //得到图形中所有的层
    115. Acad::ErrorStatus CDrawFunction::getAllLayerName(AcDbDatabase *pDb,CStringArray& layerArray)
    116. {
    117. Acad::ErrorStatus es=Acad::eOk;
    118. if(pDb==NULL)
    119. return Acad::eInalidInput;
    120. layerArray.RemoeAll();
    121. AcDbLayerTable *pLayerTable=NULL;
    122. if((es=pDb->getSymbolTable(pLayerTable,AcDb::kForRead))!=Acad::eOk)
    123. {
    124. pLayerTable->close();
    125. return es;
    126. }
    127. //创建一个层表迭代器
    128. AcDbLayerTableIterator *pLayerTableIterator;
    129. pLayerTable->newIterator(pLayerTableIterator);
    130. pLayerTable->close();

    131. char *pLayerName=NULL;
    132. CString name;
    133. for(int i=0;!pLayerTableIterator->done();pLayerTableIterator->step(),i++)
    134. {
    135. AcDbLayerTableRecord *pLayerTableRecord=NULL;
    136. pLayerTableIterator->getRecord(pLayerTableRecord,AcDb::kForRead);
    137. pLayerTableRecord->getName(pLayerName);
    138. name.Format("%s",pLayerName);
    139. pLayerTableRecord->close();
    140. layerArray.Add(name);

    141. }

    142. if(pLayerName) acutDelString(pLayerName);
    143. delete pLayerTableIterator;pLayerTableIterator=NULL;
    144. return es;
    145. }


    146. //
    147. //
    148. BOOL CDrawFunction::getLinetypeIdFromString(const char* str, AcDbObjectId& id)
    149. {
    150. //----查找安装目录----//
    151. CString AcadInstallPath;
    152. FindAcadInstallPath(AcadInstallPath);
    153. CString File=AcadInstallPath+"\\linetype\\user.lin";
    154. //-----查找完毕--------//
    155. ASSERT(str!=NULL);
    156. AcDbLinetypeTable *pLinetypeTable;
    157. acdbHostApplicationSerices()->workingDatabase()->getSymbolTable(pLinetypeTable, AcDb::kForRead);
    158. Acad::ErrorStatus mess;
    159. mess=pLinetypeTable->getAt(str,id);
    160. if(mess==Acad::eKeyNotFound||mess==Acad::ePermanentlyErased)
    161. {
    162. pLinetypeTable->close();
    163. Acad::ErrorStatus error;

    164. error=acdbLoadLineTypeFile(str,File.GetBuffer(0),acdbHostApplicationSerices()->workingDatabase());
    165. if(error==Acad::eNullObjectPointer)
    166. {
    167. AcDbLinetypeTable *pLinetypeTable;
    168. acdbHostApplicationSerices()->workingDatabase()->getSymbolTable(pLinetypeTable, AcDb::kForRead);
    169. pLinetypeTable->getAt("CONTINUOUS", id);
    170. pLinetypeTable->close();
    171. return FALSE;
    172. }
    173. else if(error==Acad::eFileSystemErr)
    174. {
    175. AfxMessageBox("the specified file cannot be opened");
    176. return FALSE;
    177. }
    178. else if(error==Acad::eUndefinedLineType)
    179. {
    180. AcDbLinetypeTable *pLinetypeTable;
    181. acdbHostApplicationSerices()->workingDatabase()->getSymbolTable(pLinetypeTable, AcDb::kForRead);
    182. AfxMessageBox("the linetype name specified by ltname is not found in the file");
    183. pLinetypeTable->getAt("CONTINUOUS", id);
    184. pLinetypeTable->close();
    185. return TRUE;
    186. }
    187. AcDbLinetypeTable *pLinetypeTable;
    188. acdbHostApplicationSerices()->workingDatabase()->getSymbolTable(pLinetypeTable, AcDb::kForRead);
    189. pLinetypeTable->getAt(str,id);
    190. pLinetypeTable->close();
    191. return TRUE;
    192. }
    193. pLinetypeTable->close();
    194. return TRUE;
    195. }



    196. oid CDrawFunction::FindAcadInstallPath(CString &AcadInstallPath)
    197. {
    198. //查找样式目录安装路径
    199. TCHAR AcadPath[255];
    200. HKEY hKey;
    201. if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,TEXT("SOFTWARE\\线路处开发组\\RDS2002\\1.00"),0,KEY_QUERY_ALUE,&hKey)!=ERROR_SUCCESS)
    202. {
    203. ::AfxMessageBox("注册路径不对");
    204. return ;
    205. }
    206. DWORD dwDataType=REG_SZ;
    207. DWORD dwLength=255;
    208. LONG lRet=RegQueryalueEx(hKey,TEXT("path"),NULL,NULL,(LPBYTE)AcadPath,&dwLength);
    209. RegCloseKey(hKey);
    210. if(lRet!=ERROR_SUCCESS)
    211. {
    212. acutPrintf("Read failed\n");
    213. return ;
    214. }
    215. //-----查找完毕--------//
    216. AcadInstallPath.Format("%s",AcadPath);
    217. }

    218. AcDbObjectId CDrawFunction::createTextStyle(CString fontName,CString bigFontName,CString textStyleName)
    219. {
    220. AcGiTextStyle *TextStyle=new AcGiTextStyle
    221. (fontName,
    222. bigFontName,
    223. 0,
    224. 0.67,
    225. 0,
    226. 0,
    227. Adesk::kFalse,
    228. Adesk::kFalse,
    229. Adesk::kFalse,
    230. Adesk::kFalse,
    231. Adesk::kFalse,
    232. textStyleName); //字体名
    233. AcDbObjectId textStyleId;
    234. toAcDbTextStyle(*TextStyle,textStyleId);
    235. return textStyleId;
    236. }



    237. //
    238. //
    239. //
    240. AcDbObjectId CDrawFunction::createMutiText(AcGePoint3d BasePoint,AcDb::TextHorzMode hMode,AcDb::TextertMode Mode,CString Text,double texthight,double widthfactor,double angle,int color,CString smallFontName,CString bigFontName,CString layerName)
    241. {
    242. ASSERT(Text!=NULL);
    243. AcDbMText *pMText=new AcDbMText();
    244. if(pMText==NULL)
    245. throw Acad::eOutOfMemory;
    246. AcDbObjectId TextStyleId;
    247. TextStyleId=createTextStyle(smallFontName,bigFontName,"xianlu");
    248. pMText->setTextStyle(TextStyleId);
    249. pMText->setContents(Text.GetBuffer(Text.GetLength()));
    250. pMText->setTextHeight(texthight);
    251. pMText->setRotation(angle);
    252. pMText->setLineSpacingFactor(0.8);
    253. pMText->setColorIndex(color);
    254. if(layerName!="")
    255. pMText->setLayer(layerName.GetBuffer(0));
    256. AcDbObjectId MTextId;
    257. addToModelSpace(MTextId, pMText);
    258. pMText->close();
    259. return MTextId;
    260. }
    复制代码
    回复


    http://www.mjgw.org/ 专业从事膜结构设计、制作加工、施工安装的膜结构工程服务,能够为客户提供专业的膜结构整体解决方案。做中国最好的膜结构综合服务平台。欢迎大家联系电话:198-7840-1958,QQ:463017170.
    相关关键词:膜结构车棚,膜结构车棚覆盖,膜结构车棚公司,膜结构车棚多少钱,膜结构车棚厂家,膜结构车棚价格,社区膜结构车棚,膜结构车棚膜布厂家 ,膜结构车棚哪家好,膜结构车棚多少钱一米,膜结构车棚报价,膜结构车棚哪里有,膜结构车棚定制,膜结构车棚安装,膜结构车棚设计,膜结构车棚电话,膜结构车棚加工,膜结构车棚膜布价格,膜结构车棚批发,膜结构车棚制造商,膜结构车棚生产厂家,膜结构车棚设计,膜结构车棚施工,膜结构车棚多少钱一平米,膜结构车棚订制,张拉膜车棚,张拉膜车棚覆盖,张拉膜车棚公司,张拉膜车棚多少钱,张拉膜车棚厂家,张拉膜车棚价格,社区张拉膜车棚,张拉膜车棚膜布厂家 ,张拉膜车棚哪家好,张拉膜车棚多少钱一米,张拉膜车棚报价,张拉膜车棚哪里有,张拉膜车棚定制,张拉膜车棚安装,张拉膜车棚设计,张拉膜车棚电话,张拉膜车棚加工,张拉膜车棚膜布价格,张拉膜车棚批发,张拉膜车棚制造商,张拉膜车棚生产厂家,张拉膜车棚设计,张拉膜车棚施工,张拉膜车棚多少钱一平米,张拉膜车棚订制,常用膜材品牌:德国杜肯、法国法拉利、德国海德斯、德国米乐、日本平岗、韩国秀博、比利时希运、美国赫虏伯、中国科宝、上海慧遥。

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    推荐膜材品牌上一条 /6 下一条

    进口膜材 国产膜材 pvdf膜材ptfe膜材ETFE膜材
    最好的膜结构公司 一级膜结构资质 膜结构一级资质
    膜结构设计-膜结构十大品牌-etfe设计-充气膜结构
    诺科膜结构
    遨都膜结构设计
    中国膜结构网
    中国空间膜结构

    QQ|申请友链|手机版|中国膜结构论坛