[求助]请问大虾这个功能怎样实现?
<b><BR></b>1.我想将一个信息附加在单行文本上,例如"data001",2.在复制这个文本的时候自动把附加信息也一起复制
3.在我更改这个文本的时候,自动搜索跟他附加信息一样的单行文本,然后改成相同的。 1、2
可以使用扩展数据
3、在更改这个文本的时候,自动搜索跟他扩展数据一样的单行文本,然后改成相同的 原理我知道,但是不知怎样下手。
没做过关于扩展数据的程序?有没有例子或者帮助? CAD的帮助里就有呀,GetXData方法和SetXData方法 CAD的帮助
lineObj.<FONT style="BACKGROUND-COLOR: #316ac5" color=#ffffff>GetXData</FONT> "", xtypeOut, xdataOut
“”里面是不是application name
xtypeOut ,xdataOut
返回的东西怎样读取利用阿?
<BR> 以前写的
Sub setxRecord()
Dim linext(0 To 4) As Integer<BR>Dim linexd(0 To 4) As Variant<BR>Dim sPoint(0 To 2) As Double<BR>Dim ePoint(0 To 2) As Double<BR>sPoint(0) = 10<BR>sPoint(1) = 10<BR>sPoint(2) = 0<BR>ePoint(0) = 30<BR>ePoint(1) = 30<BR>ePoint(2) = 0<BR>Dim lineObj As AcadLine<BR>Set lineObj = ThisDrawing.ModelSpace.addline(sPoint, ePoint)<BR>lineObj.Color = 1
linext(0) = 1001: linexd(0) = "LineInfo"<BR>linext(1) = 1000: linexd(1) = "a"<BR>linext(2) = 1000: linexd(2) = "b"<BR>linext(3) = 1000: linexd(3) = "c"<BR>linext(4) = 1000: linexd(4) = "d"
ThisDrawing.RegisteredApplications.Add "LineInfo"<BR>lineObj.SetXData linext, linexd<BR>lineObj.Update
End Sub
Sub getxRecord()<BR>Dim a As Variant<BR>Dim b As Variant<BR>Dim sset As AcadSelectionSet<BR>Set sset = ThisDrawing.SelectionSets.Add("ss")<BR>Dim point As Variant<BR>point = ThisDrawing.Utility.GetPoint()<BR>sset.SelectAtPoint point<BR>Dim entry As AcadEntity<BR>Dim xdataOut As Variant<BR>Dim xtypeOut As Variant<BR> <BR>For Each entry In sset<BR> If StrComp(entry.ObjectName, "AcDbLine", 1) = 0 Then<BR> entry.GetXData "", xtypeOut, xdataOut<BR> MsgBox xdataOut(1)<BR> End If<BR>Next<BR>ThisDrawing.SelectionSets.Item("ss").Delete<BR>End Sub<BR> DataType(0) = 1001: Data(0) = "Test_Application"<BR> DataType(1) = 1000: Data(1) = "This is a test for xdata"<BR><BR> DataType(2) = 1003: Data(2) = "0" ' layer<BR> DataType(3) = 1040: Data(3) = 1.23479137438413E+40 ' real<BR> DataType(4) = 1041: Data(4) = 1237324938 ' distance<BR> DataType(5) = 1070: Data(5) = 32767 ' 16 bit Integer<BR> DataType(6) = 1071: Data(6) = 32767 ' 32 bit Integer<BR> DataType(7) = 1042: Data(7) = 10 ' scaleFactor<BR><BR> reals3(0) = -2.95: reals3(1) = 100: reals3(2) = -20<BR> DataType(8) = 1010: Data(8) = reals3 ' real<BR> <BR> worldPos(0) = 4: worldPos(1) = 400.99999999: worldPos(2) = 2.798989<BR> DataType(9) = 1011: Data(9) = worldPos ' world space position<BR>
除了1001以外,其他好像不需要连续,但编号还有什么规定呢?跟所占的空间有没有关系?
楼上的
linext(1) = 1000: linexd(1) = "a"<BR>linext(2) = 1000: linexd(2) = "b"<BR>linext(3) = 1000: linexd(3) = "c"<BR>linext(4) = 1000: linexd(4) = "d"
怎么都是1000啊? 我把yulijin608的代码改到vb.net中有错。改后的代码如下:
Sub setxRecord(ByRef acadDoc As AutoCAD.AcadDocument)
Dim linext(4) As Integer<BR> Dim linexd(4) As String<BR> Dim sPoint(2) As Double<BR> Dim ePoint(2) As Double<BR> sPoint(0) = 10<BR> sPoint(1) = 10<BR> sPoint(2) = 0<BR> ePoint(0) = 50<BR> ePoint(1) = 50<BR> ePoint(2) = 0<BR> Dim lineObj As AutoCAD.AcadLine<BR> lineObj = acadDoc.ModelSpace.AddLine(sPoint, ePoint)<BR> lineObj.color = 1
linext(0) = 1001 : linexd(0) = "LineInfo"<BR> linext(1) = 1000 : linexd(1) = "a"<BR> linext(2) = 1000 : linexd(2) = "b"<BR> linext(3) = 1000 : linexd(3) = "c"<BR> linext(4) = 1000 : linexd(4) = "d"
acadDoc.RegisteredApplications.Add("LineInfo")<BR> lineObj.SetXData(linext, linexd) ‘这里出错,
lineObj.Update()
End Sub
出错原因,我猜可能是object和Variant类型不匹配,我把object改成string也不行,不知道应该怎么改?那位知道怎么改,还请指点一下啊?<BR> DataType数组的值表示Data数组的类型,1000,说明对应项是字符串
.net里应该是:
Dim linext(4) As Short
Dim linexd(4) As Object 本帖最后由 作者 于 2005-6-2 11:19:53 编辑
多谢版主指点!
页:
[1]