阻止布局
抱歉,我的基本问题提前...我希望用户选择绘图标题块并在我的WPF窗口中显示所有属性(可能在列表框中...)。我无法到达属性集合...我对XAML和WPF还是很陌生,我应该将任何东西绑定到我的列表框吗?此时我正在使用模态窗口...任何建议都将不胜感激...Private Sub SelectTargetedBlock_Click(sender As Object, e As Windows.RoutedEventArgs) Handles SelectTargetedBlock.Click
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim db As Database = doc.Database
'this - is the modal dialog box.
Using UI As EditorUserInteraction = ed.StartUserInteraction(Me)
Dim entResult As PromptEntityResult = ed.GetEntity(vbLf & "Select entity")
If entResult.StatusPromptStatus.OK Then
Return
End If
Using Tx As Transaction = db.TransactionManager.StartTransaction()
' Dim obj As DBObject = Tx.GetObject(entResult.ObjectId, OpenMode.ForRead)
Dim BlkRef As BlockReference = Tx.GetObject(entResult.ObjectId, OpenMode.ForRead)
Dim attCol As AttributeCollection = BlkRef.AttributeCollection
For Each attId As ObjectId In attCol
Dim attRef As AttributeReference = TryCast(Tx.GetObject(attId, OpenMode.ForRead), AttributeReference)
Next
Tx.Commit()
End Using
End Using
End Sub
End Class
**** Hidden Message ***** Djee,我想您需要将每个attref添加到列表中,然后将列表框绑定到列表中
我不会说VB,但它看起来可能是这样的:
将attList设置为List
=new List
…
对于attCol中作为ObjectId的每个阁楼
Dim attRef作为AttributeReference=TryCast(Tx.GetObject(attId,OpenMode.ForRead),AttributeReference)
attList.Add(attRef)
下一个
…
<div>myListbox。DataSource=attList
虽然我期待着其他人的一些答案,但MC总是在开发一些很酷的WPF/数据绑定功能。
嗨,我不是一个VB.net的家伙,这里是我在C#中用下面的方法建立一个属性字符串列表的尝试: public static ListPrintAttributesToCommandLine(Database db,Document doc,Editor ed)。
{。
var lst = new List ();。
尝试一下。
{ 。
使用(事务tr = db,transaction manager . start transaction())。
{。
typed value[]TV = { new typed value(0," INSERT)",new TypedValue(66,1)};。
PromptSelectionResult sel = ed,GetSelection(新选择过滤器(电视));。
if (sel,Status == PromptStatus,好)。
{。
foreach (ObjectId obj in sel,value . get objectid())。
{。
块参考rf =(块参考)tr,GetObject(obj,OpenMode。for read);。
中频(射频,属性集合!= null)。
{。
foreach(RF中的ObjectId id,AttributeCollection)。
{。
attribute reference att =(attribute reference)trGetObject(id,OpenMode。for read);。
if (att,TextString!= "")。
lst,添加(附件,text string);。
}。
}。
}。
}。
trcommit();。
} 。
}。
catch(系统,例外情况,例如)。
{。
ed,write message(" \ n错误:{0} ",例如。消息);。
}。
返回lst。
}。
感谢大家让我开始!因此,我最终创建了一个ObservableCollection类&将我的列表框绑定到该类的一个属性(attribute标记)…到目前为止,一切似乎都正常工作。WPF/XAML山很难攀登…
Private Sub SelectTargetedBlock_Click(sender As Object, e As Windows.RoutedEventArgs) Handles SelectTargetedBlock.Click
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim db As Database = doc.Database
'this - is the modal dialog box.
Using UI As EditorUserInteraction = ed.StartUserInteraction(Me)
Dim entResult As PromptEntityResult = ed.GetEntity(vbLf & "Select entity")
If entResult.StatusPromptStatus.OK Then
Return
End If
Using Tx As Transaction = db.TransactionManager.StartTransaction()
' Dim obj As DBObject = Tx.GetObject(entResult.ObjectId, OpenMode.ForRead)
Dim BlkRef As BlockReference = Tx.GetObject(entResult.ObjectId, OpenMode.ForRead)
If BlkRef.AttributeCollection IsNot Nothing Then
Dim attCol As AttributeCollection = BlkRef.AttributeCollection
For Each attId As ObjectId In attCol
Dim attRef As AttributeReference = TryCast(Tx.GetObject(attId, OpenMode.ForRead), AttributeReference)
MyObjectSource.Add(New MyAttribute With {
.BlkTagToLookAt = attRef.Tag,
.DestinationBlkName = attRef.BlockName})
Next
End If
Tx.Commit()
End Using
End Using
Dim b As New Binding("BlkTagToLookAt")
b.Mode = BindingMode.OneWay
b.Source = MyObjectSource
BindingOperations.SetBinding(MyListBox, TextBox.TextProperty, b)
MyListBox.DataContext = MyObjectSource
页:
[1]