[求助]如何能获得NURBS实体的DXF组值
<p><shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" opreferrelative="t" ospt="75" coordsize="21600,21600"> </shapetype><img src="file:///D:/未命名.bmp" border="0" alt=""/></p><p>这是Nurbs曲线实体段的组码和说明,想提取次数,节点值,权值和控制点值</p><p>但是以前没用过CAD的VBA</p><p>哪位高手能举例说明一下怎么提取么?</p><p>比如</p><p>刚看来得</p><p class="MsoNormal" style="BACKGROUND: white; MARGIN: 24pt 0cm 12pt; WORD-BREAK: break-all; mso-pagination: widow-orphan; mso-outline-level: 1;">Dim objSel As AcadEntity</p><p><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt;"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt;"><p class="MsoNormal" style="BACKGROUND: white; MARGIN: 24pt 0cm 12pt; WORD-BREAK: break-all; mso-pagination: widow-orphan; mso-outline-level: 1;"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt;">If objSel.ObjectName <> "AcDbSpline" Then‘<span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-bidi-font-family: Tahoma;">选择的不是 AcDbSpline,.....</span></p><p class="MsoNormal" style="BACKGROUND: white; MARGIN: 24pt 0cm 12pt; WORD-BREAK: break-all; mso-pagination: widow-orphan; mso-outline-level: 1;"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Tahoma; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA;">我想判断如果组码值为71,把值赋给k</span></p><p class="MsoNormal" style="BACKGROUND: white; MARGIN: 24pt 0cm 12pt; WORD-BREAK: break-all; mso-pagination: widow-orphan; mso-outline-level: 1;"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Tahoma; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA;">如果组码值 为10,把值付给一个数组x</span></p><p class="MsoNormal" style="BACKGROUND: white; MARGIN: 24pt 0cm 12pt; WORD-BREAK: break-all; mso-pagination: widow-orphan; mso-outline-level: 1;"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Tahoma; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA;">一些关键字不知用什么 啊</span></p><p class="MsoNormal" style="BACKGROUND: white; MARGIN: 24pt 0cm 12pt; WORD-BREAK: break-all; mso-pagination: widow-orphan; mso-outline-level: 1;"> </p><p class="MsoNormal" style="BACKGROUND: white; MARGIN: 24pt 0cm 12pt; WORD-BREAK: break-all; mso-pagination: widow-orphan; mso-outline-level: 1;"> </p><p></p></span><p></p></span></p></span> 没人知道么? <p>你判断组码为了甚么呢?VBA里好像只能判断对象的属性,判断组码好像无从下手,你想实现甚么呢?不一定非要判断组码的吧?</p> <p>我想将样条曲线的阶次,控制顶点坐标,权值以及节点值提取出来,用于二次开发啊</p><p>不能实现么?</p> <p class="body" style="MARGIN: auto 0cm;">这个功能VB可以实现,VBA不可以么?</p><p class="body" style="MARGIN: auto 0cm;">以下是一个简单的 Visual Basic 6 程序样例,它读取 DXF 文件,并且从给定段的给定对象中提取特定代码和值。</p><pre><font face="宋体">' ReadDXF 从 DXF 文件中提取指定的代码/值对。</font></pre><pre><font face="宋体">' 此函数需要四个字符串参数、一个有效的 DXF</font></pre><pre><font face="宋体">' 文件名、一个 DXF 段名、该段中对象的</font></pre><pre><font face="宋体">' 名称以及由逗号分隔的代码列表。</font></pre><pre><font face="宋体">'</font></pre><pre><font face="宋体">Function ReadDXF( _</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ByVal dxfFile As String, ByVal strSection As String, _</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ByVal strObject As String, ByVal strCodeList As String)</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> Dim tmpCode, lastObj As String</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> Open dxfFile For Input As #1</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>获取第一个代码/值对</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> codes = ReadCodes</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>遍历整个文件,直到“EOF”行</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> While codes(1) <> "EOF"</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>如果组码为“<chmetcnv wst="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="0" unitname="”">0”</chmetcnv>,并且值为“SECTION”,则</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> If codes(0) = "0" And codes(1) = "SECTION" Then</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>这必须是一个新的段,以便获取下一个</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>代码/值对。</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> codes = ReadCodes()</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>如果此段是要获取的段,则</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> If codes(1) = strSection Then</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>获取下一个代码/值对,并</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> codes = ReadCodes</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>遍历此段,直到“ENDSEC”</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> While codes(1) <> "ENDSEC"</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>在某段中,所有的“<chmetcnv wst="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="0" unitname="”">0”</chmetcnv>代码都表示</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>对象。 如果找到了“<chmetcnv wst="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="0" unitname="”">0”</chmetcnv>代码,则存储</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>对象名称,供以后使用。</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> If codes(0) = "0" Then lastObj = codes(1)</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>如果此对象是用户所需的对象,</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> If lastObj = strObject Then</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>则在代码前后加上逗号</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> tmpCode = "," & codes(0) & ","</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>如果此代码位于代码列表中,</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> If InStr(strCodeList, tmpCode) Then</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>则附加返回值。</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ReadDXF = ReadDXF & _</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> codes(0) & "=" & codes(1) & vbCrLf</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> End If</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> End If</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>读取其他代码/值对</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> codes = ReadCodes</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> Wend</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> End If</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> </span>否则</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> codes = ReadCodes</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> End If</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> Wend</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> Close #1</font></span></pre><pre><font face="宋体">End Function</font></pre><pre><font face="宋体">' ReadCodes 从打开的文件中读取两行,并返回一个包含两个项目</font></pre><pre><font face="宋体">' 的数组、一个组码及其组码值。 只要一次读取 DXF 文件中的两行代码,</font></pre><pre><font face="宋体">' 所有程序应该都能够顺利运行。 但为了使代码
</font></pre><pre><font face="宋体">' 更可靠,应该添加一些进行错误检查和其他</font></pre><pre><font face="宋体">' 检查的代码。</font></pre><pre><font face="宋体">'</font></pre><pre><font face="宋体">Function ReadCodes() As Variant</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> Dim codeStr, valStr As String</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> Line Input #1, codeStr</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> Line Input #1, codeStr</font></span></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ' </span>修剪代码中的前导空格和后续空格</font></pre><pre><font face="宋体"><span style="mso-spacerun: yes;"> ReadCodes = Array(Trim(codeStr), valStr)</font></span></pre><pre><font face="宋体">End Function</font></pre><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><p><font face="Times New Roman"> </font></p></p> <p>如果是读取dxf文件的话,VB和VBA都一样的,但想直接从图形中判断组码,应该就不行了,看看其他高手有妙招没有!</p>
页:
[1]