草榴网 (H5前端CAD平台)在线CAD若何终了图形识别功能|图元|角点|cad|包围盒
发布日期:2024-10-08 05:45 点击次数:106
序论草榴网
CAD图形识别功能可匡助用户快速识别和索取CAD图纸中的各式图形,从而加快假想进程。可应用在识别与分类阶段,自动识别图纸中的不同元素,通过特定特征进行分手,减少了手动分类的职责量;也可应用在数目统计阶段,统计图纸中各式构件的数目用于预算;还可诳骗在图纸定位和应用阶段,快速定位图纸上的特定元素,便于快速查找和修改。
mxcad为用户提供了图形识别功能和API,用户可字据自己需求对该功能进行拓展或二次开拓,更从容文档柔和公Z号:守望云图网页CAD。
图形识别尺度
1. 通达mxcad在线示例demo:demo.mxdraw3d.com:3000/mxcad/
2. 点击【器具(A)】菜单栏,找到图形识别功能,选拔【图形识别】按钮,如下图:
3. 字据高歌行辅导,点击鼠标左键点选图元或拉框选拔需要识别的图形(图形识别功能现在相沿识别直线类、多段线类、曲线类、圆类,以及块这五类图元)草榴网,如下图:
4. 点击右键扫尾选拔后,在弹出的图形识别框内成就查找图形笃信,成就图形称呼可便捷后续查找已识别图形;成就重新选拔图形时,会隐秘面前选中图形;成就区域查找时,需要用户框选查找界限,若未框选界限则会默许为全图纸查找图形,如下图:
5. 在图形识别框内点击【开动识别】按钮,开动在磋议界限内查找图形,并将查找限度展示在图形识别列表中。点击图形识别列表下的坐标对应的【稽查】按钮会自动定位到对应的图形位置,并圈选出磋议图形,如下图:
五月桃色网6.当识别多个图形后,可点击磋议图形统计表格对应的操作列中的【笃信】按钮稽查识别笃信,图形坐标列表将调治为该磋议图形的识别限度,如下图:
识别留神事项:
要是需要识别的图形较为复杂,为保证识别速率与精度,咱们需尽可能查找图形中的畸形部分而不是录取通盘这个词图形(图形对象过多时可能会导致卡顿,影响用户使用恶果)。图形识别相沿区域选拔,用户可字据自己需求精准定位图形筛选区域。
功能开拓
mxcad 图形识别功能中诳骗的中枢想想是通过[McDbEntity]实体中每个实体的特征在图纸中进行查找,查找的实体中包括了[直线类]、[多段线类]、[曲线类]、[圆类],以及[块]。
下列为基于mxcad 封装的图形识别类SearchSamePattern用户可字据该类的使用措施利用 mxcad 进行二次开拓,代码如下:
import {DxfCode, McCmColor, McDbArc, McDbBlockReference, McDbCircle, McDbLine, McDbPolyline, McDbWipeout, McGePoint3d,McGePoint3dArray, McGeVector3d, MxCADResbuf, MxCADSelectionSet, MxCADUtility, MxCpp} from "mxcad";import { MxFun } from "mxdraw";export class SearchSamePattern {/** 识别图元数 */private objectCount: number = 0;/** 选拔图形蚁合 Map*/private selectObjects: any;private dTol = 0.000001;/*** pt1:左下角* pt2:右上角* pt3:左上角* pt4:右下角*/private pt1: McGePoint3d;private pt2: McGePoint3d;private pt3: McGePoint3d;private pt4: McGePoint3d;//包围盒大小private pl: McDbPolyline;/** 识别图形类名蚁合 [string] */private classNames: any/** 识别图形图片地址 */private patternImgUrl: String/** 识别对象笃信 Map*/private objectsDetails: any = {};// 下列为识别限度数据/** 识别后的图形位置数组蚁合 */;private graphBoxsPos: any[] = [];private formPt: McGePoint3d;private toPt: McGePoint3d;/** 点精度值 */private dTolPt: any;/** 识别后图形列表 */private patternList: any = {};/** 选拔的图形蚁合 */public setSelectset(ss: MxCADSelectionSet): Promise {if (!ss?.count()) return;const mxcad = MxCpp.getCurrentMxCAD();// 获稳当前图纸的空间块表纪录包围盒const { maxPt, minPt } = mxcad.getDatabase().currentSpace.getBoundingBox();const currentDrawOrder = mxcad.getDatabase().currentSpace.getMinMaxDrawOrder()const n = MxFun.screenCoordLong2Doc(Math.abs(maxPt.x - minPt.x));minPt.x -= n; minPt.y -= n; maxPt.x += n; maxPt.y += n;let points = new McGePoint3dArray();points.append(minPt);points.append(new McGePoint3d(minPt.x, maxPt.y, 0));points.append(new McGePoint3d(maxPt.x, maxPt.y, 0));points.append(new McGePoint3d(maxPt.x, minPt.y, 0));this.objectCount = ss.count();// 获得遮罩层drawOrderlet wipeout = new McDbWipeoutwipeout.setVertices(points);const wipeoutId = mxcad.drawEntity(wipeout);const e = wipeoutId.getMcDbEntity();e.drawOrder = currentDrawOrder.maxDrawOrder + 1;this.selectObjects = {};const oldDrawOder = [];ss.forEach(id => {const ent = id.getMcDbEntity();/** 纪录识别图形的信息 */if (!this.selectObjects[ent.objectName]) this.selectObjects[ent.objectName] = [];this.selectObjects[ent.objectName].push(ent);if (ent.objectName === 'McDbLine') {if (!this.objectsDetails['McDbLine']) this.objectsDetails['McDbLine'] = [];this.objectsDetails['McDbLine'].push({ entity: ent, length: (ent as McDbLine).getLength().val });} else if (ent.objectName === 'McDbArc') {if (!this.objectsDetails['McDbArc']) this.objectsDetails['McDbArc'] = [];const length = (ent as McDbArc).getLength().val;const { bugle } = this.getBugle((ent as McDbArc), length)this.objectsDetails['McDbArc'].push({ entity: ent, length, bugle });} else if (ent.objectName === 'McDbCircle') {if (!this.objectsDetails['McDbCircle']) this.objectsDetails['McDbCircle'] = [];const radius = (ent as McDbCircle).radius;this.objectsDetails['McDbCircle'].push({ entity: ent, radius });} else if (ent.objectName === 'McDbBlockReference') {if (!this.objectsDetails['McDbBlockReference']) this.objectsDetails['McDbBlockReference'] = [];const blkName = (ent as McDbBlockReference).blockName;this.objectsDetails['McDbBlockReference'].push({ entity: ent, blkName });} else if (ent.objectName === 'McDbPolyline') {if (!this.objectsDetails['McDbPolyline']) this.objectsDetails['McDbPolyline'] = [];const length = (ent as McDbPolyline).getLength().val;this.objectsDetails['McDbPolyline'].push({ entity: ent, length });}/** 渲染规则 */oldDrawOder.push({ obj: ent, drawOrder: ent.drawOrder });ent.drawOrder = e.drawOrder + 1;const { maxPt草榴网, minPt } = ent.getBoundingBox();if (!this.pt1
上一篇:女同 sex 搜狐影音