我最近研究了这个问题,当不使用Arx时,这是相当困难的。
我确实有代码为颜色创建自定义组合框,但无法使线型位图工作。如果你愿意,我可以给你密码。
我提出的最佳解决方案是使用AutoCAD对话框。链接到datagrid表单。
颜色
- Public Function UserGetColor() As Autodesk.AutoCAD.Colors.Color
- Dim DiaLineWT As New Autodesk.AutoCAD.Windows.ColorDialog
- Dim Result As System.Windows.Forms.DialogResult = DiaLineWT.ShowModal()
- If Result = System.Windows.Forms.DialogResult.OK Then
- Return DiaLineWT.Color
- Else
- Return Nothing
- End If
- End Function
线路重量
- Public Shared Function UserGetLineWeight() As LineWeight
- Dim DiaLineWT As New Autodesk.AutoCAD.Windows.LineWeightDialog
- Dim Result As System.Windows.Forms.DialogResult = DiaLineWT.ShowModal()
- If Result = System.Windows.Forms.DialogResult.OK Then
- Return DiaLineWT.LineWeight
- Else
- Return Nothing
- End If
- End Function
线型
- Shared Function UserGetLineType() As LinetypeTableRecord
- Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
- Dim db As Database = doc.Database
- Try
- Using tr As Transaction = db.TransactionManager.StartTransaction
- Dim ltt As LinetypeTable = tr.GetObject(db.LinetypeTableId, OpenMode.ForRead)
- Dim ltID As ObjectId = ShowLineTypeDialog()
- Dim ltr As LinetypeTableRecord = TryCast(tr.GetObject(ltID, OpenMode.ForRead, False), LinetypeTableRecord)
- If ltr IsNot Nothing Then
- Return ltr
- Else
- Return Nothing
- End If
- End Using
- Catch ex As Autodesk.AutoCAD.Runtime.Exception
- doc.Editor.WriteMessage(ex.Message)
- Return Nothing
- End Try
- End Function
|