CaveMan 发表于 2022-7-6 22:34:13

VB。“网络线型”对话框

很好的一天
 
我希望从AutoCAD线型对话框中获取线型名称,如下所示:
 

 
我想使用线型名称——我生成的代码只以字符串形式返回ID——找不到哪个参数将以字符串形式返回线型名称??
 

Private Sub But_LTCon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles But_LTCon.Click
Dim xLineType As String
xLineType = ShowLineTypeDialog()
Txt_LTCon.Text = xLineType.ToString
LtypeCon = xLineType.ToString
End Sub

 

Public Function ShowLineTypeDialog()
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Dim xLIneTypeDialog As New LinetypeDialog()
Dim dr As System.Windows.Forms.DialogResult
dr = xLIneTypeDialog.ShowDialog()
If dr = Windows.Forms.DialogResult.OK Then
Dim SelLineType As String
SelLineType = xLIneTypeDialog.Linetype.ToString (Returns ID want the Name?)
Return SelLineType
ElseIf dr = Windows.Forms.DialogResult.Cancel Then
Return "Cancell"
End If
End Function

 
任何帮助-非常感谢
 
当做
穴居人

fixo 发表于 2022-7-6 22:56:28

也许是这样(A22009)

      Public Function ShowLineTypeDialog() As ObjectId
         Dim xLIneTypeDialog As New Autodesk.AutoCAD.Windows.LinetypeDialog()
         Dim dr As System.Windows.Forms.DialogResult
         dr = xLIneTypeDialog.ShowDialog()
         If dr = System.Windows.Forms.DialogResult.OK Then
               Dim SelLineType As ObjectId = xLIneTypeDialog.Linetype
               Return SelLineType
         ElseIf dr = System.Windows.Forms.DialogResult.Cancel Then
               Return ObjectId.Null
         End If
       End Function
       <CommandMethod("LTDia")> _
       Public Sub TestLinetypeDialog()
         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
                     Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(ltr.Name + vbLf + ltr.AsciiDescription)
                   End If
               End Using
         Catch ex As Autodesk.AutoCAD.Runtime.Exception
               doc.Editor.WriteMessage(ex.Message)
         End Try
       End Sub

 
~'J'~

CaveMan 发表于 2022-7-6 23:26:42

很好的一天
 
非常感谢您的示例代码
谢谢你,我的应用程序运行良好。
 
享受周末
当做
穴居人

fixo 发表于 2022-7-6 23:36:57

很高兴我能帮忙
祝你周末愉快
 
~'J'~
页: [1]
查看完整版本: VB。“网络线型”对话框