Hot News:

Mit Unterstützung durch:

  Foren auf CAD.de (alle Foren)
  CATIA V5 Programmierung
  FTA Capture / View / Camera renaming

Antwort erstellen  Neues Thema erstellen
CAD.de Login | Logout | Profil | Profil bearbeiten | Registrieren | Voreinstellungen | Hilfe | Suchen

Anzeige:

Darstellung des Themas zum Ausdrucken. Bitte dann die Druckfunktion des Browsers verwenden. | Suche nach Beiträgen nächster neuer Beitrag | nächster älterer Beitrag
Autor Thema:  FTA Capture / View / Camera renaming (57 / mal gelesen)
Sylas
Mitglied



Sehen Sie sich das Profil von Sylas an!   Senden Sie eine Private Message an Sylas  Schreiben Sie einen Gästebucheintrag für Sylas

Beiträge: 348
Registriert: 19.11.2012

Dell Precision T3500
Intel Xeon W3550 @ 3,07 GHz
12 GB RAM
CATIA V5 R28

erstellt am: 27. Jun. 2024 11:43    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities

Hello Community!

I'm trying to write a code to automatically rename captures / views / cameras.

The problem occures when there's more then one capture based on (supported by) the same view. What I want in this case is to preserve viewm name from the first rename occurance. Instead of that - my code renames it each time  I tried to use ActiveViewState property, but it seems not working. Below my code - maybe someone could give me some tips...

Code:

Sub CATMain()
'On Error Resume Next
Dim oAnnSet As AnnotationSet
Dim odSel As Selection
Dim oSel
Dim InputObjectType(1) As Variant
Dim oTable() As Variant
Dim oPart As Part
Dim oDoc As Document

Set odSel = CATIA.ActiveDocument.Selection
Set oSel = odSel
InputObjectType(0) = "Product"
InputObjectType(1) = "Part"
Result = oSel.SelectElement2(InputObjectType, "Choose FTA", True)
If TypeName(oSel.Item(1).Value) = "Product" Then
    Set oPart = oSel.Item(1).Value.ReferenceProduct.Parent.Part
    Set oDoc = oSel.Item(1).Value.ReferenceProduct.Parent
Else
    Set oPart = oSel.Item(1).Value
    Set oDoc = oSel.Item(1).Value.Parent
End If
Dim oAnnotationSets As AnnotationSets
Set oAnnotationSets = oPart.AnnotationSets
Set oAnnSet = oAnnotationSets.Item(1)
Dim oCapture As Capture
Dim oCamera As Camera3D
Dim oActiveView As TPSView
Dim oNameTable() As Variant
ReDim oNameTable(oAnnSet.Captures.Count - 1)
'captures naming pass 1
For i = oAnnSet.Captures.Count To 1 Step -1
    Set oCapture = oAnnSet.Captures.Item(i)
    If Left(oCapture.Name, 2) <> "C." Then
        oCapture.Name = "C." & oCapture.Name
    End If
Next
'captures naming pass 2
For i = oAnnSet.Captures.Count To 1 Step -1
    Set oCapture = oAnnSet.Captures.Item(i)
    If Left(oCapture.Name, 3) = "C. " Then
        oCapture.Name = Replace(oCapture.Name, "C. ", "C.", , 1)
    End If
Next
'captures naming pass 3
For i = oAnnSet.Captures.Count To 1 Step -1
    Set oCapture = oAnnSet.Captures.Item(i)
    If InStr(1, oCapture.Name, "/") <> 0 Then
        If InStr(1, Mid(oCapture.Name, InStr(1, oCapture.Name, "/") - 1, 3), " ") = 0 Then
                oCapture.Name = Replace(oCapture.Name, "/", " / ", , 1)
        End If
    End If
Next
'cameras and views renaming
'Set oActiveView = Nothing
'For i = oAnnSet.Captures.Count To 1 Step -1
For i = 1 To oAnnSet.Captures.Count
    Set oCapture = oAnnSet.Captures.Item(i)
    Set oCamera = oCapture.Camera
    'cameras naming
    If InStr(1, oCapture.Name, " / ") <> 0 Then
        oCamera.Name = Mid(oCapture.Name, 3, InStr(1, oCapture.Name, " / ") - 3)
    ElseIf InStr(1, oCapture.Name, "/") <> 0 Then
        oCamera.Name = Mid(oCapture.Name, 3, InStr(1, oCapture.Name, "/") - 3)
    Else
        oCamera.Name = Mid(oCapture.Name, 3)
    End If
    If oCapture.ActiveViewState = True Then        '<------ this should work for captures without supporting view, but it's not :(
        Set oActiveView = oCapture.ActiveView
        oActiveView.Name = Mid(oCapture.Name, 3, Len(oCapture.Name))
    End If
    oNameTable(i - 1) = oCamera.Name
    'Set oActiveView = Nothing
Next

oSel.Clear
'deleting unused cameras
For j = oDoc.Cameras.Count To 1 Step -1
    If IsInArray(oDoc.Cameras.Item(j).Name, oNameTable) = False Then
            oDoc.Cameras.Remove j
    End If
Next
MsgBox ("Done!")
End Sub


Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Anzeige.:

Anzeige: (Infos zum Werbeplatz >>)

Darstellung des Themas zum Ausdrucken. Bitte dann die Druckfunktion des Browsers verwenden. | Suche nach Beiträgen

nächster neuerer Beitrag | nächster älterer Beitrag
Antwort erstellen


Diesen Beitrag mit Lesezeichen versehen ... | Nach anderen Beiträgen suchen | CAD.de-Newsletter

Administrative Optionen: Beitrag schliessen | Archivieren/Bewegen | Beitrag melden!

Fragen und Anregungen: Kritik-Forum | Neues aus der Community: Community-Forum

(c)2024 CAD.de | Impressum | Datenschutz