julianwoo 发表于 2010-1-16 10:47:00

[求助]任意图形加最大外形框

现在有一大批图档要求算装箱,谁能帮忙编个只要框选一下就能把奇形怪状的产品图的最大外形用图框包住,最好加上个中心线,谢谢。

ljttjl 发表于 2010-1-16 19:59:00

<p>上传个例图看一下。</p>

cfu18 发表于 2010-1-18 16:58:00

本帖最后由 作者 于 2010-1-18 17:38:21 编辑 <br /><br /> <pre>ads_name ents;<br/>&nbsp;if(ads_ssget(NULL,NULL,NULL,NULL,ents) == RTNORM)<br/>&nbsp;{<br/>&nbsp;&nbsp;AcDbExtents ext;<br/>&nbsp;&nbsp;long nLen = 0;<br/>&nbsp;&nbsp;ads_sslength(ents,&amp;nLen);<br/>&nbsp;&nbsp;long i = 0;<br/>&nbsp;&nbsp;for (; i &lt; nLen; i++)<br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;ads_name curEnt;<br/>&nbsp;&nbsp;&nbsp;ads_ssname(ents,i,curEnt);<br/>&nbsp;&nbsp;&nbsp;AcDbObjectId curId;<br/>&nbsp;&nbsp;&nbsp;if(acdbGetObjectId(curId,curEnt) != Acad::eOk)<br/>&nbsp;&nbsp;&nbsp;&nbsp;continue;<br/>&nbsp;&nbsp;&nbsp;AcDbEntity * pEnt = NULL;<br/>&nbsp;&nbsp;&nbsp;acdbOpenAcDbEntity(pEnt,curId,AcDb::kForRead);<br/>&nbsp;&nbsp;&nbsp;if (pEnt == NULL)<br/>&nbsp;&nbsp;&nbsp;&nbsp;continue;<br/>&nbsp;&nbsp;&nbsp;AcDbExtents curExt;<br/>&nbsp;&nbsp;&nbsp;pEnt-&gt;getGeomExtents(curExt);<br/>&nbsp;&nbsp;&nbsp;ext.addExt(curExt);<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;ads_ssfree(ents);</pre><pre>&nbsp;&nbsp;AcDbDatabase * pDb = acdbCurDwg();<br/>&nbsp;&nbsp;if (pDb == NULL)<br/>&nbsp;&nbsp;&nbsp;return;<br/>&nbsp;&nbsp;AcDbBlockTable * pBlock = NULL;<br/>&nbsp;&nbsp;pDb-&gt;getBlockTable(pBlock,AcDb::kForWrite);<br/>&nbsp;&nbsp;if (pBlock == NULL)<br/>&nbsp;&nbsp;&nbsp;return;<br/>&nbsp;&nbsp;AcDbBlockTableRecord * pRecord = NULL;<br/>&nbsp;&nbsp;pBlock-&gt;getAt(ACDB_MODEL_SPACE,pRecord,AcDb::kForWrite);<br/>&nbsp;&nbsp;if (pRecord == NULL)<br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;pBlock-&gt;close();<br/>&nbsp;&nbsp;&nbsp;return;<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;pBlock-&gt;close();<br/>&nbsp;<br/>&nbsp;&nbsp;//绘制矩形<br/>&nbsp;&nbsp;AcDbPolyline *pPolyExt = new AcDbPolyline;<br/>&nbsp;&nbsp;pPolyExt-&gt;addVertexAt(0,AcGePoint2d(ext.minPoint().x,ext.minPoint().y));<br/>&nbsp;&nbsp;pPolyExt-&gt;addVertexAt(1,AcGePoint2d(ext.minPoint().x,ext.maxPoint().y));<br/>&nbsp;&nbsp;pPolyExt-&gt;addVertexAt(2,AcGePoint2d(ext.maxPoint().x,ext.maxPoint().y));<br/>&nbsp;&nbsp;pPolyExt-&gt;addVertexAt(3,AcGePoint2d(ext.maxPoint().x,ext.minPoint().y));<br/>&nbsp;&nbsp;pPolyExt-&gt;setClosed(Adesk::kTrue);<br/>&nbsp;&nbsp;//绘制中心线<br/>&nbsp;&nbsp;AcDbLine * pVLn = new AcDbLine,* pHLn = new AcDbLine;<br/>&nbsp;&nbsp;pVLn-&gt;setStartPoint(AcGePoint3d((ext.minPoint().x+ext.maxPoint().x)*0.5,ext.minPoint().y,0));<br/>&nbsp;&nbsp;pVLn-&gt;setEndPoint(AcGePoint3d((ext.minPoint().x+ext.maxPoint().x)*0.5,ext.maxPoint().y,0));<br/>&nbsp;&nbsp;pHLn-&gt;setStartPoint(AcGePoint3d(ext.minPoint().x,(ext.minPoint().y+ext.maxPoint().y)*0.5,0));<br/>&nbsp;&nbsp;pHLn-&gt;setEndPoint(AcGePoint3d(ext.maxPoint().x,(ext.minPoint().y+ext.maxPoint().y)*0.5,0));</pre><pre>&nbsp;&nbsp;pRecord-&gt;appendAcDbEntity(pPolyExt);<br/>&nbsp;&nbsp;pRecord-&gt;appendAcDbEntity(pVLn);<br/>&nbsp;&nbsp;pRecord-&gt;appendAcDbEntity(pHLn);<br/>&nbsp;&nbsp;pPolyExt-&gt;close();<br/>&nbsp;&nbsp;pVLn-&gt;close();<br/>&nbsp;&nbsp;pHLn-&gt;close();<br/>&nbsp;&nbsp;pRecord-&gt;close();<br/>&nbsp;}</pre><pre>&nbsp;</pre>

julianwoo 发表于 2010-1-19 09:53:00

<p>能够发个编译好的给我吗?谢谢</p>

julianwoo 发表于 2010-1-30 10:26:00

<p>论坛有好心人能把这编译成 *.arx发给我吗?谢谢!308553484@qq.com</p>

cfu18 发表于 2010-2-3 13:00:00

要什么版本的

caoyao_1987 发表于 2011-8-28 13:41:45

大哥啊,有没有LISP的呀?

水仙的错 发表于 2019-9-14 13:51:59

很多人需要这样的源码

hnzkhyyl 发表于 2023-4-22 09:11:26

cfu18 发表于 2010-1-18 16:58
本帖最后由 作者 于 2010-1-18 17:38:21 编辑ads_name ents;&nbsp;if(ads_ssget(NULL,NULL,NULL,NULL,en ...

怎么加入到LISP中去
页: [1]
查看完整版本: [求助]任意图形加最大外形框