[求助] 一个SetXData的错误
<p></p><p>各位大师,</p><p>小弟的代码在SetXData时发生了如下错误:“运行时错误'-2147352567(80020009)':方法‘’SetXData”作用于‘IAcadLine’时失败”</p><p>能给帮忙解决一下吗?</p><p>这厢有礼了</p><p>Dim Spoint As Variant<br/> Dim Epoint As Variant<br/> Dim objline As AcadLine<br/> <br/> rmd1 = "输入起点"<br/> rmd2 = "输入终点"<br/> <br/> Spoint = ThisDrawing.Utility.GetPoint(, rmd1)<br/> Epoint = ThisDrawing.Utility.GetPoint(Spoint, rmd2)<br/> <br/> Set objline = ThisDrawing.ModelSpace.AddLine(Spoint, Epoint)<br/> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br/> Dim mchjigg As String<br/> Dim dengji As String<br/> Dim jshtj As String<br/> Dim gdh As String<br/> Dim XDType(0 To 4) As Integer<br/> Dim XData(0 To 4) As Variant<br/> <br/> XDType(0) = 1001<br/> XData(0) = "waibu"<br/> XDType(1) = 1000<br/> XData(1) = "AA" </p><p>XDType(2) = 1003<br/> XData(2) = "BB" </p><p>XDType(3) = 1004<br/> XData(3) = "cc" <br/> XDType(4) = 1005<br/> XData(4) = "DD" <br/> objline.SetXData XDType, XData<br/> </p> <p>帮助文件!</p><p>Organization of Extended Data</p><div class="head-margin"> </div><div style="LINE-HEIGHT: 0pt;"> </div><div class="head-margin"> </div><a name="WS73099cc142f4875516d84be10ebc87a53f-7a06"></a><!--Element not supported - Type: 8 Name: #comment--><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62dd"></a>Extended data consists of one or more 1001 groups, each of which begins with a unique application name. The xdata groups returned by <em class="codeEmphasisStrong">entget</em> follow the definition data in the order in which they are saved in the database.</p><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62dc"></a>Within each application's group, the contents, meaning, and organization of the data are defined by the application. AutoCAD maintains the information but does not use it. The table also shows that the group codes for xdata are in the range 1000-1071. Many of these group codes are for familiar data types, as follows:</p><dl><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-642e"></a>String</span></dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62db"></a>1000. Strings in extended data can be up to 255 bytes long (with the 256th byte reserved for the null character).</p></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-642d"></a>Application Name</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62da"></a>1001 (also a string value). Application names can be up to 31 bytes long (the 32nd byte is reserved for the null character) and must adhere to the rules for symbol table names (such as layer names). An application name can contain letters, digits, and the special characters $ (dollar sign), - (hyphen), and _ (underscore). It cannot contain spaces. </p></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-642c"></a>Layer Name</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62d9"></a>1003. Name of a layer associated with the xdata.</p></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-642b"></a>Database -Handle</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62d8"></a>1005. Handle of an entity in the drawing database.</p></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-642a"></a>3D Point</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62d7"></a>1010. Three real values, contained in a point.</p></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-6429"></a>Real</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62d6"></a>1040. A real value.</p></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-6428"></a>Integer</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62d5"></a>1070. A 16-bit integer (signed or unsigned).</p></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-6427"></a>Long</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62d4"></a>1071. A 32-bit signed (long) integer. If the value that appears in a 1071 group is a short integer or real value, it is converted to a long integer; if it is invalid (for example, a string), it is converted to a long zero (0L).</p><div><div class="note-note">NoteAutoLISP manages 1071 groups as real values. If you use <em class="codeEmphasisStrong">entget</em> to retrieve an entity's definition list that contains a 1071 group, the value is returned as a real, as shown in the following example:</div></div><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62d3"></a>(1071 . 12.0)</p><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62d2"></a>If you want to create a 1071 group in an entity with <em class="codeEmphasisStrong">entmake</em> or <em class="codeEmphasisStrong">entmod</em>, you can use either a real or an integer value, as shown in the following example:</p><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62d1"></a>(entmake '((..... (1071 . 12) .... )))</p><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62d0"></a>(entmake '((..... (1071 . 12.0) .... )))</p><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62cf"></a>(entmake '((..... (1071 . 65537.0) .... )))</p><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62ce"></a>(entmake '((..... (1071 . 65537) .... )))</p><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62cd"></a>But AutoLISP still returns the group value as a real:</p><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62cc"></a>(entmake '((..... (1071 . 65537) .... )))</p><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62cb"></a>The preceding statement returns the following: </p><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62ca"></a>(1071 . 65537.0)</p><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62c9"></a>ObjectARX always manages 1071 groups as long integers.</p></div></dd></dl><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62c8"></a>Several other extended data groups have special meanings in this context (if the application chooses to use them):</p><dl><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-6426"></a>Control String</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62c7"></a>1002. An xdata control string can be either "{" or "}". These braces enable the application to organize its data by subdividing it into lists. The left brace begins a list, and the right brace terminates the most recent list. Lists can be nested.</p><div><div class="note-note">NoteIf a 1001 group appears within a list, it is treated as a string and does not begin a new application group.</div></div></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-6425"></a>Binary Data</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62c6"></a>1004. Binary data that is organized into variable-length chunks, which can be handled in ObjectARX with the ads_binary structure. The maximum length of each chunk is 127 bytes.</p><div><div class="note-note">NoteAutoLISP cannot directly handle binary chunks, so the same precautions that apply to long (1071) groups apply to binary groups as well.</div></div></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-6424"></a>World Space Position</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62c5"></a>1011. Unlike a simple 3D point, the WCS coordinates are moved, scaled, rotated, and mirrored along with the parent entity to which the extended data belongs. The WCS position is also stretched when the STRETCH command is applied to the parent entity and when this point lies within the select window.</p></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-6423"></a>World Space -Displacement</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62c4"></a>1012. A 3D point that is scaled, rotated, or mirrored along with the parent, but not stretched or moved.</p></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-6422"></a>World -Direction</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62c3"></a>1013. A 3D point that is rotated or mirrored along with the parent, but not scaled, stretched, or moved. The WCS direction is a normalized displacement that always has a unit length.</p></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-6421"></a>Distance</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62c2"></a>1041. A real value that is scaled along with the parent entity.</p></div></dd><dt><span style="DISPLAY: none;"><a name="WSfacf1429558a55de11f0759ff1e4b858c-6420"></a>Scale Factor</span>
</dt><dd><div class="definition"><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62c1"></a>1042. Also a real value that is scaled along with the parent. </p></div></dd></dl><p><a name="WSfacf1429558a55de11f0759ff1e4b858c-62c0"></a>The DXF group codes for xdata are also described in the <em class="mild">DXF Reference</em>.</p> 明白了,非常感谢帮助。
页:
[1]