Hi Leute!
Ich habe mir ein Makro runtergeladen. Es wandelt drawings in dwg um. Das Problem ist, das es die Layer nur als Zahlen ausgibt, wenn ich Buchstaben ins Makro reinschreibe kommt eine Fehlermeldung. Gibt es da schnelle Abhilfe oder ist das komplizierter?
Hier ist die Zeile um die es geht: CATIA.ActiveDocument.Selection.VisProperties.SetLayer catVisLayerBasic, 2
In dieser Zeile wird im Autocad als Layername "2" ausgegeben ich würde dort gerne "Koerperkanten" ausgegeben haben.
MfG Marco
'*****************************************************************
'*
'* Programm zum umwandeln von CATIA (V4 +) V5 Draftings in ACAD - Dwg's
'*
'* Erstellt : 03.03.2008 -
'* V0.1 Alle Drafting's eines Verzeichnisses einlesen und als Dwg speichern
'* V0.2 Farben nach ACAD-Tabelle Setzen
'* V0.3 Layer Zuordnung von ACAD benutzen
'* (V0,4 Blatt Namen auslesen und setzen! - Sonst nur SmarTeam Nr)
'*
'*
'*****************************************************************
Dim documents1 As Documents
Dim document1 As Document
Dim drawingDocument1 As Document
Dim drawingSheets1 As DrawingSheets
Dim drawingSheet1 As DrawingSheet
Dim selection1 As Selection
Dim selection2 As Selection
Dim specsAndGeomWindow1 As Window
Dim Geos As GeometricElements
Dim Geo As GeometricElement
Dim zaehler As Integer
Dim namen ( 200 ) As String
Dim Farben As String
Sub CATMain()
MsgBox "Tool : DRW_V5_TO_ACAD-Dwg" & chr(13) & chr(10) & chr(13) & chr(10) & chr(13) & chr(10) & "Erklärung:" & chr(10) & chr(13) &"Nach dem Öffnen EINER Drafting aus dem Start- / Zielverzeichnis"& chr(13) & chr(10)&"werden nacheinander ALLE Draftings in ACAD-Dwg-Dateien umgewandelt." & chr(13) & chr(10) & chr(13) & chr(10) &"Alle Kanten werden beim umwandeln auf die jeweiligen ACAD Layer und Farben gesetzt." & chr(13) & chr(10) & chr(13) & chr(10)
WandleFarbe=0
WandleFarbe = InputBox ("Sollen allen Kanten ACAD Farben zugeordnet werden?" & chr(13) & chr(10) & chr(13) & chr(10) &chr(13) & chr(10) &"Farben nicht ändern : 0"& chr(10) &chr(13) & chr(10) &"Farben ändern : 1"& chr(10) &chr(13) & chr(10) & chr(10) &chr(13) & chr(10) , Farben )
filename =Catia.FileSelectionBox ("Datei Öffnen","*.CATDrawing", CATFileSelectionModeOpen)
If filename <>"" Then
trennzeichen = "\"
values = Split ( filename, trennzeichen )
For i=0 To 100 Step 1
If (InStr( values(i),".CATDrawing")) <> 0 Then
Exit For
End If
Pfad=Pfad & values( i ) & "\"
Next
End If
If filename <>"" Then
folderinput = Pfad
folderoutput =folderinput
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderinput)
Set fc = f.Files
For Each f1 in fc
Set documents1 = CATIA.Documents
PFADEINGABE = folderinput & f1.name
If (InStr( PFADEINGABE,".CATDrawing")) <> 0 Then
Set document1 = documents1.Open(PFADEINGABE)
Set drawingDocument1 = CATIA.ActiveDocument
drawingDocument1.Standard = 1
Set drawingSheets1 = drawingDocument1.Sheets
'****************** Anzahl Blätter ************************************
Counter1 = drawingSheets1.Count
For I=1 to Counter1
Name1 = CATIA.ActiveDocument.Sheets.Item(I).Name
' MsgBox ( CATIA.ActiveDocument.Sheets.Item(I).Name )
Set drawingSheet1 = drawingSheets1.Item( I )
drawingSheet1.Activate
Set drawingDocument1 = CATIA.ActiveDocument
'***************************************************** Farbe ändern ?
Set drawingDocument1 = CATIA.ActiveDocument
Set selection1 = drawingDocument1.Selection
'**** Koerperkannten Layer 0 - Weiß
CATIA.ActiveDocument.Selection.Search "Weight=0,35mm,all"
If ( WandleFarbe = 1 ) then
CATIA.ActiveDocument.Selection.VisProperties.SetRealColor 0,0,0,1
End If
CATIA.ActiveDocument.Selection.VisProperties.SetLayer catVisLayerBasic, 2
CATIA.ActiveDocument.Selection.Clear
'**** Koerperkannten Layer 1 - dunkelrot
'**** Koerperkannten Layer 2 - blau
'**** Verdeckte Kanten Layer 3 - magenta
' CATIA.ActiveDocument.Selection.Search "Weight=0,13mm,all"
CATIA.ActiveDocument.selection.Search "Dashed=3,all"
If ( WandleFarbe = 1 ) then
CATIA.ActiveDocument.Selection.VisProperties.SetRealColor 128,0,64,1
End If
CATIA.ActiveDocument.Selection.VisProperties.SetLayer catVisLayerBasic, 3
CATIA.ActiveDocument.Selection.Clear
'**** Hilfslinien Layer 4 - grün
CATIA.ActiveDocument.selection.Search "(Dashed=1 & Weight=0,13mm),all"
If ( WandleFarbe = 1 ) then
CATIA.ActiveDocument.Selection.VisProperties.SetRealColor 14,224,77,1
End If
CATIA.ActiveDocument.Selection.VisProperties.SetLayer catVisLayerBasic, 4
CATIA.ActiveDocument.Selection.Clear
'**** Bemaßung Layer 5 - grün
CATIA.ActiveDocument.selection.Search "CATDrwSearch.DrwDimension,all"
If ( WandleFarbe = 1 ) then
CATIA.ActiveDocument.Selection.VisProperties.SetRealColor 14,224,77,1
End If
CATIA.ActiveDocument.Selection.VisProperties.SetLayer catVisLayerBasic, 5
CATIA.ActiveDocument.Selection.Clear
'**** Text Layer 6 - blau
CATIA.ActiveDocument.selection.Search "CATDrwSearch.DrwText,all"
If ( WandleFarbe = 1 ) then
CATIA.ActiveDocument.Selection.VisProperties.SetRealColor 0,0,255,1
End If
CATIA.ActiveDocument.Selection.VisProperties.SetLayer catVisLayerBasic, 6
CATIA.ActiveDocument.Selection.Clear
'**** Mittellinie Layer 7 - cyan
CATIA.ActiveDocument.Selection.Search "CATDrwSearch.DrwCenterLine,all"
If ( WandleFarbe = 1 ) then
CATIA.ActiveDocument.Selection.VisProperties.SetRealColor 0,255,255,1
End If
CATIA.ActiveDocument.Selection.VisProperties.SetLayer catVisLayerBasic, 7
CATIA.ActiveDocument.Selection.Clear
'**** Schraffur Layer 8 - rot
' CATIA.ActiveDocument.selection.Search "CATDrwSearch.DrwAreaFill,all"
CATIA.ActiveDocument.selection.Search "CATDrwSearch.CATEarlyGenShape,all"
If ( WandleFarbe = 1 ) then
CATIA.ActiveDocument.Selection.VisProperties.SetRealColor 224,40,14,1
End If
CATIA.ActiveDocument.Selection.VisProperties.SetLayer catVisLayerBasic, 8
CATIA.ActiveDocument.Selection.Clear
'**** Schnittlinie Layer 2A - Weiß
' CATIA.ActiveDocument.selection.Search "CATDrwSearch.DrwView,all"
' If ( WandleFarbe = 1 ) then
' CATIA.ActiveDocument.Selection.VisProperties.SetRealColor 0,0,0,1
' End If
' CATIA.ActiveDocument.Selection.VisProperties.SetLayer catVisLayerBasic, 0
' CATIA.ActiveDocument.Selection.Clear
'**** Phantomlinien Layer 4A - grün
' CATIA.ActiveDocument.Selection.Clear
'--------------------------- Speichern Unter -------------------------------------------------
trennzeichen = "."
SaveName=f1.name As String
values = Split ( SaveName, trennzeichen )
If Counter1>1 Then
PFADAUSGABE = folderoutput &values(0) & "_Bl" & I & ".dwg"
Else
PFADAUSGABE = folderoutput &values(0) & ".dwg"
End If
drawingDocument1.ExportData PFADAUSGABE, "dwg"
Next
Set specsAndGeomWindow1 = CATIA.ActiveWindow
specsAndGeomWindow1.Close
Set drawingDocument1 = CATIA.ActiveDocument
drawingDocument1.Close
s = s & f1.name & vbCrLf
End If
Next
MsgBox "fertig !" & vbCrLf & s
End If
End Sub
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP