乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 58|回复: 3

阻止布局

[复制链接]

15

主题

44

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
104
发表于 2016-6-30 11:42:22 | 显示全部楼层 |阅读模式
抱歉,我的基本问题提前...我希望用户选择绘图标题块并在我的WPF窗口中显示所有属性(可能在列表框中...)。我无法到达属性集合...我对XAML和WPF还是很陌生,我应该将任何东西绑定到我的列表框吗?此时我正在使用模态窗口...任何建议都将不胜感激...
  1.   Private Sub SelectTargetedBlock_Click(sender As Object, e As Windows.RoutedEventArgs) Handles SelectTargetedBlock.Click
  2.         Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
  3.         Dim ed As Editor = doc.Editor
  4.         Dim db As Database = doc.Database
  5.         'this - is the modal dialog box.
  6.         Using UI As EditorUserInteraction = ed.StartUserInteraction(Me)
  7.             Dim entResult As PromptEntityResult = ed.GetEntity(vbLf & "Select entity")
  8.             If entResult.Status  PromptStatus.OK Then
  9.                 Return
  10.             End If
  11.             Using Tx As Transaction = db.TransactionManager.StartTransaction()
  12.                 ' Dim obj As DBObject = Tx.GetObject(entResult.ObjectId, OpenMode.ForRead)
  13.                 Dim BlkRef As BlockReference = Tx.GetObject(entResult.ObjectId, OpenMode.ForRead)
  14.                 Dim attCol As AttributeCollection = BlkRef.AttributeCollection
  15.                 For Each attId As ObjectId In attCol
  16.                     Dim attRef As AttributeReference = TryCast(Tx.GetObject(attId, OpenMode.ForRead), AttributeReference)
  17.                 Next
  18.                 Tx.Commit()
  19.             End Using
  20.         End Using
  21.     End Sub
  22. End Class

本帖以下内容被隐藏保护;需要你回复后,才能看到!

游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

85

主题

404

帖子

7

银币

中流砥柱

Rank: 25

铜币
751
发表于 2016-6-30 13:41:43 | 显示全部楼层
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/数据绑定功能。
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2016-6-30 13:53:06 | 显示全部楼层
嗨,我不是一个VB.net的家伙,这里是我在C#中用下面的方法建立一个属性字符串列表的尝试:    public static List  PrintAttributesToCommandLine(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。
}。
回复

使用道具 举报

15

主题

44

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
104
发表于 2016-6-30 15:34:19 | 显示全部楼层
感谢大家让我开始!因此,我最终创建了一个ObservableCollection类&将我的列表框绑定到该类的一个属性(attribute标记)…到目前为止,一切似乎都正常工作。WPF/XAML山很难攀登…
  1.   Private Sub SelectTargetedBlock_Click(sender As Object, e As Windows.RoutedEventArgs) Handles SelectTargetedBlock.Click
  2.         Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
  3.         Dim ed As Editor = doc.Editor
  4.         Dim db As Database = doc.Database
  5.         'this - is the modal dialog box.
  6.         Using UI As EditorUserInteraction = ed.StartUserInteraction(Me)
  7.             Dim entResult As PromptEntityResult = ed.GetEntity(vbLf & "Select entity")
  8.             If entResult.Status  PromptStatus.OK Then
  9.                 Return
  10.             End If
  11.             Using Tx As Transaction = db.TransactionManager.StartTransaction()
  12.                 ' Dim obj As DBObject = Tx.GetObject(entResult.ObjectId, OpenMode.ForRead)
  13.                 Dim BlkRef As BlockReference = Tx.GetObject(entResult.ObjectId, OpenMode.ForRead)
  14.                 If BlkRef.AttributeCollection IsNot Nothing Then
  15.                     Dim attCol As AttributeCollection = BlkRef.AttributeCollection
  16.                     For Each attId As ObjectId In attCol
  17.                         Dim attRef As AttributeReference = TryCast(Tx.GetObject(attId, OpenMode.ForRead), AttributeReference)
  18.                         MyObjectSource.Add(New MyAttribute With {
  19.                     .BlkTagToLookAt = attRef.Tag,
  20.                     .DestinationBlkName = attRef.BlockName})
  21.                     Next
  22.                 End If
  23.                 Tx.Commit()
  24.             End Using
  25.         End Using
  26.         Dim b As New Binding("BlkTagToLookAt")
  27.         b.Mode = BindingMode.OneWay
  28.         b.Source = MyObjectSource
  29.         BindingOperations.SetBinding(MyListBox, TextBox.TextProperty, b)
  30.         MyListBox.DataContext = MyObjectSource
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-2-4 18:57 , Processed in 0.144345 second(s), 60 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表