Hallo liebe Forengemeinde,
bin als passiver User schon länger im Forum unterwegs und habe schon so einige hilfreiche Infos zur Makroprogrammierung erhalten. Dafür mal eine herzliches Dankeschön.
Nun bin ich aber auf ein Problem gestoßen, dass ich auch nach langer Recherche nicht lösen kann...
Ich nutze den CATIA "Standard Zeichnungsrahmen" (Programmiert in CATScript) der Customized wurde. Dieses Skript will ich nun in ein anderes VBA Makro einbauen. Das Starten des CATSkript via VBA klappt mit:
Code:
Dim CatSysServ As Variant
Dim Param()Set CatSysServ = CATIA.SystemService
CatSysServ.ExecuteScript Pfad_Rahmen, catScriptLibraryTypeDirectory, Rahmen_Test, "CATMain", Param
Das Problem ist die Deklaration im CATScript die ich nicht hinbekomme. Das targetSheet ist als CATIABase im original Quelltext deklariert. Das ist warscheinlich notwendig für das manuelle Auswahl des Makros über Backround View --> Insert --> Drawing --> Frame and Title Block. Meine Frage ist nun wie muss die Variable targetSheet deklarieren damit der Zeichnungsrahmen auf dem aktuellen Drawingsheet eingefügt wird?
Code:
Sub CATMain()
If Not CATInit(targetSheet) Then Exit Sub
On Error Resume Next
name = Texts.GetItem("Reference_" + GetMacroID()).Name
If Err.Number <> 0 Then
Err.Clear
name = "none"
End If
On Error Goto 0
If (name = "none") Then
CATDrw_Erstellen
Else
CATDrw_Blattformat
CATDrw_Aktualisieren
End If
CATExit
End SubFunction CATInit( targetSheet as CATIABase )
'-------------------------------------------------------------------------------
'How to init the dialog and create main objects
'-------------------------------------------------------------------------------
Set Selection = CATIA.ActiveDocument.Selection
Set Sheet = targetSheet
Set Sheets = Sheet.Parent
Set ActiveDoc = Sheets.Parent
Set Views = Sheet.Views
Set View = Views.Item(2)'Get the background view
Set Texts = View.Texts
Set Fact = View.Factory2D
If GetContext()="Unexpected" Then
Msg = "The macro runs in an inappropriate environment."&chr(13)&"The script will terminate wihtout finishing the current action."
Title ="Unexpected environement error"
MsgBox Msg,16, Title
CATInit=FALSE 'Exit with error
Exit Function
End If
Selection.Clear
CATIA.HSOSynchronized=False
'Exit without error
CATInit=TRUE 'Exit without error
End Function
Sub CATDrw_Erstellen( targetSheet as CATIABase )
'-------------------------------------------------------------------------------
'How to create the FTB
'-------------------------------------------------------------------------------
If Not CATInit(targetSheet) Then Exit Sub
If CATCheckRef(1) Then Exit Sub 'To check whether a FTB exists already in the sheet
CATCreateReference 'To place on the drawing a reference point
CATFrame 'To draw the frame
CATCreateTitleBlockFrame 'To draw the geometry
CATTitleBlockText 'To fill in the title block
CATColorGeometry 'To change the geometry color
CATExit targetSheet 'To save the sketch edition
CATCreateTitleBlockStandard()
End Sub
Fehler ist folgender:
Ich hoffe jemand kann mir weiterhelfen.
Schon mal vielen Dank. Gruß LaBam
[Diese Nachricht wurde von LaBam am 14. Dez. 2017 editiert.]
[Diese Nachricht wurde von LaBam am 15. Dez. 2017 editiert.]
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP