| | | Gut zu wissen: Hilfreiche Tipps und Tricks aus der Praxis prägnant, und auf den Punkt gebracht für Autodesk Produkte |
Autor
|
Thema: Fehlerroutinen schreiben ? (1068 mal gelesen)
|
Dirk.B Mitglied Tischler / Leiter Arbeitsvorbereitung
Beiträge: 534 Registriert: 25.11.2003
|
erstellt am: 11. Jan. 2011 13:22 <-- editieren / zitieren --> Unities abgeben:
Hallo zusammen! Hatte mir mal ein kleines Tool geschrieben um Werte in einen Schriftfeldblock zu schreiben. Dieses hatte ich bislang immer nur auf den Papierbereich angewendet. Folgende Fehleroutinen möchte ich nun noch einbauen: - Ist der Modelbereich aktiv, soll eine MsgBox darauf hinweisen und das Programm beenden. - Ist der Papierbereich aktiv und ein Block mit dem entsprechenden Namen vorhanden ok, wenn nicht soll auch hier eine MsgBox darauf hinweisen und das Programm beenden. Modul:
Code:
Sub User_Dialog() StartMask.Show End Sub
UserForm:
Code:
Public Sub UserForm_Initialize() Dim BlockRef As AcadBlockReference Dim BlockEntity As AcadEntityOn Error GoTo Err_Control If ThisDrawing.ActiveLayout.Name = "Model" Then MsgBox "Dieses Tool ist nur im Papierbereich einsetzbar.", 64, "Hinweis" Exit Sub Else For Each BlockEntity In ThisDrawing.ActiveLayout.Block If BlockEntity Is Nothing Then Exit Sub If TypeOf BlockEntity Is AcadBlockReference Then Set BlockRef = BlockEntity If BlockRef.Name <> "Schriftfeld" Then MsgBox "Es ist kein Schriftfeld vorhanden." _ , 64, "Hinweis" Exit Sub Else AttWert = BlockRef.GetAttributes End If End If Next End If Err_Control: If Err Then MsgBox Err.Description StartMask.TB_BBVH1.Text = UCase(LTrim(AttWert(0).TextString)) StartMask.TB_BBVH2.Text = UCase(LTrim(AttWert(1).TextString)) StartMask.TB_GEZDAM.Text = UCase(LTrim(AttWert(2).TextString)) ... ... End Sub
Hiermit bekomme ich allerdings die Meldung "Typen unverträglich". Könnte mir da jemand weiterhelfen? Vielen Dank im Voraus. ------------------ Gruß Dirk Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Carsten1210 Mitglied staatl. geprüfter Holztechniker
Beiträge: 1357 Registriert: 24.07.2002 AutoCAD ACA 2018 Solidworks 2016 Sp5 Enterprise PDM 2016 Sp5 Pascam Woodworks Visual Studio 2017 Pro Windows 10 64Bit Dell T3620 Intel Core i7-7700K 16 GB Arbeitsspeicher 2x Samsung S24C650 Dell M4800
|
erstellt am: 11. Jan. 2011 20:59 <-- editieren / zitieren --> Unities abgeben: Nur für Dirk.B
|
Dirk.B Mitglied Tischler / Leiter Arbeitsvorbereitung
Beiträge: 534 Registriert: 25.11.2003
|
erstellt am: 12. Jan. 2011 20:50 <-- editieren / zitieren --> Unities abgeben:
Hallo Carsten! Danke für den Denkanstoß! Habe nun alles in das Modul gepackt und nun funktionierts. Modul:
Code:
Sub User_Dialog() '##--Variablenfestlegung--!!! Dim sset As AcadSelectionSet Dim BlockObj As AcadObject Dim BlockEnt As Variant Dim minPkt As Variant Dim maxPkt As Variant'Dim varAttributes As Variant 'Dim strAttributes As String Dim BlockData(1) As Variant Dim BlockType(1) As Integer BlockType(0) = 0 'Suche ElemBlockEnttyp BlockData(0) = "INSERT" 'Blockreferenz BlockType(1) = 2 'Suche Attribut, Blockname BlockData(1) = "Schriftfeld" 'Name des Blockes '##--per If ... Then die Fehlerroutine steuern--!!! If ThisDrawing.ActiveSpace = acModelSpace Then MsgBox "Dieses Tool ist nur im Papierbereich einsetzbar.", 64, "Hinweis" '--Ist der Modelbereich aktiv wird das Programm abgebrochen--! Exit Sub Else On Error GoTo 0 ThisDrawing.ActiveSpace = acPaperSpace ThisDrawing.ActiveLayout = ThisDrawing.ActiveLayout On Error Resume Next Set sset = ActiveDocument.SelectionSets.Add("Temp") If Err <> 0 Then Set sset = ActiveDocument.SelectionSets("Temp") End If On Error GoTo 0 ReDim minPkt(0 To 2) As Double ReDim maxPkt(0 To 2) As Double minPkt = ThisDrawing.GetVariable("ExtMin") maxPkt = ThisDrawing.GetVariable("ExtMax") sset.Select acSelectionSetWindow, minPkt, maxPkt, BlockType, BlockData If sset.Count = 0 Then MsgBox "Kein Schriftfeld vorhanden", 64, "Hinweis" '--Ist der Papierbereich aktiv aber kein Schriftfeld vorhanden--! '--wird das Programm abgebrochen--------------------------------! Exit Sub Else For Each BlockEnt In sset Set BlockObj = BlockEnt If BlockObj.ObjectName = "AcDbBlockReference" Then If BlockObj.HasAttributes Then AttWert = BlockObj.GetAttributes End If End If Next BlockEnt sset.Clear sset.Delete End If StartMask.Show End If End Sub
------------------ Gruß Dirk Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
| Anzeige.:
Anzeige: (Infos zum Werbeplatz >>)
|