Issue with Vault revision table

Issue with Vault revision table

mgrenier2
Advocate Advocate
156 Views
5 Replies
Message 1 of 6

Issue with Vault revision table

mgrenier2
Advocate
Advocate

I'm having a very annoying issue with Vault and Job Processor.

 

Whenever the Job Processor updates the revision table, the revision table gets moved around to a random(but maybe not so random) spot on my sheet.

 

I came up with an iLogic rule to move the rev table to where i should go, however, when I adapt code to loop through all the sheets in the drawing, Inventor just crashes, everytime.

 

Here's the one I have that is working(only for 1 sheet, I have to run it on every sheet)

Sub Main()
    Dim app As Application = ThisApplication
    Dim oDoc As DrawingDocument = app.ActiveDocument
    If oDoc Is Nothing Then Exit Sub
    If oDoc.DocumentType <> kDrawingDocumentObject Then Exit Sub

    Dim oSheet As Sheet = oDoc.ActiveSheet
    If oSheet.RevisionTables.Count = 0 Then Exit Sub

    Dim oRevTable As RevisionTable = oSheet.RevisionTables.Item(1)

    ' Coin inférieur gauche du cartouche
    Dim cartouchePos As Point2d = oSheet.TitleBlock.Position

    ' Décalage depuis le coin inférieur gauche du cartouche (en cm)
    Dim offsetX As Double = 4*2.54   ' ex.: 2 cm depuis le bord gauche du cartouche
    Dim offsetY As Double = 4.75*2.54   ' ex.: 0.5 cm depuis le bord bas du cartouche

    ' Point cible bas-gauche du tableau sur la feuille
    Dim targetX As Double = cartouchePos.X + offsetX
    Dim targetY As Double = cartouchePos.Y + offsetY

    ' Boîte englobante actuelle du tableau
    Dim box As Box2d = oRevTable.RangeBox
    Dim anchor As Point2d = oRevTable.Position

    ' Vecteur du point d’ancrage actuel vers le bas-gauche réel
    Dim vX As Double = box.MinPoint.X - anchor.X
    Dim vY As Double = box.MinPoint.Y - anchor.Y

    ' Calculer le nouvel ancrage pour aligner le bas-gauche sur la cible
    Dim TG As TransientGeometry = app.TransientGeometry
    Dim newAnchor As Point2d = TG.CreatePoint2d(targetX - vX, targetY - vY)

    ' Positionner le tableau
    oRevTable.Position = newAnchor
End Sub

 

Here's the one that crashes IV every single time I run it

Sub Main()
    Dim app As Application = ThisApplication
    Dim oDoc As DrawingDocument = app.ActiveDocument
    If oDoc Is Nothing Then Exit Sub
    If oDoc.DocumentType <> kDrawingDocumentObject Then Exit Sub

    Dim offsetX As Double = 4*2.54
    Dim offsetY As Double = 4.75*2.54

    For Each oSheet As Sheet In oDoc.Sheets
        ' Vérifier qu'il y a au moins un tableau
        If oSheet.RevisionTables.Count = 0 Then Continue For

        Dim oRevTable As RevisionTable = oSheet.RevisionTables.Item(1)

        ' Vérification préalable : uniquement si la feuille est active
        If oSheet.Name <> oDoc.ActiveSheet.Name Then
            ' Skip ou copier les valeurs du tableau pour éviter le crash
            Continue For
        End If

        ' Coin inférieur gauche du cartouche
        Dim cartouchePos As Point2d = oSheet.TitleBlock.Position
        Dim targetX As Double = cartouchePos.X + offsetX
        Dim targetY As Double = cartouchePos.Y + offsetY

        ' Boîte englobante du tableau
        Dim box As Box2d = oRevTable.RangeBox
        Dim anchor As Point2d = oRevTable.Position

        Dim vX As Double = box.MinPoint.X - anchor.X
        Dim vY As Double = box.MinPoint.Y - anchor.Y

        Dim TG As TransientGeometry = app.TransientGeometry
        Dim newAnchor As Point2d = TG.CreatePoint2d(targetX - vX, targetY - vY)

        oRevTable.Position = newAnchor
    Next
End Sub

 

So is there any way for my rule to loop through my sheets without Inventor dying?

0 Likes
Accepted solutions (1)
157 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor
Accepted solution

It looks like you need to 'activate' each sheet, just inside the loop of sheets, using the Sheet.Activate method.  This is necessary because it can not pull locational data or measurements from inactive sheets in the background.  It was probably trying to do the same thing to the same sheet each time.  Then you can get rid of the sheet name check block of code also.

 

Edit:  And by the way, the document type check at the beginning is in the wrong order.  Once you have set the active document to the drawing type variable, and it was not a drawing type, the error would have already happened before it got to the document type check later.  So the document type check either needs to happen before, or at the same time as setting the value of the specific type document variable.  If the document variable was a generic type, like Document, instead of DrawingDocument, then it would not be a problem, but then you have less 'Intellisense' help also.

    Dim oDoc As DrawingDocument = app.ActiveDocument
    If oDoc Is Nothing Then Exit Sub
    If oDoc.DocumentType <> kDrawingDocumentObject Then Exit Sub

could be changed to:

    Dim oDoc As DrawingDocument = TryCast(app.ActiveDocument, DrawingDocument )
    If oDoc Is Nothing Then Exit Sub

When using TryCast, it will not throw an error if it fails to Cast the 'active' document of a different Type to the Type you want...it simply will not assign a value to the variable.  But the next line of code has that possibility covered.   There is also the Application.ActiveDocumentType property that could be checked before even getting the active document.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

mgrenier2
Advocate
Advocate

Thanks a lot

0 Likes
Message 4 of 6

mgrenier2
Advocate
Advocate

Well, since iLogic won't trigger when the job processor performs its edits, it's back to square one I guess. I hate this software, for real

0 Likes
Message 5 of 6

WCrihfield
Mentor
Mentor

I'm going through a lot of 'growing pains' right now too, since we just got Vault for the first time just a few weeks ago.  It has been a ton of disruptions and complexity involved just in the process of getting all our decades of pre-existing stuff put into it (which were still not completely done with).  There were a lot more 'issues' (missing Links, duplicates, and more) than we ever imagined, not to mention all the new settings that we have to figure out.  I have already been looking into the 'Vault API' related stuff too, which so far seems to be exponentially more complex, and requires tons more code to get anything done, when compared to doing stuff with Inventor's API.  Yay...not. 😒😞 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 6

mgrenier2
Advocate
Advocate

I can't wait for the day Autodesk finally gets rid of all this :

 

Design Assistant

Style library manager

Task manager

Drawing ressource transfer tool

Job processor

 

Just to name a few

 

They should all be part of the main software, not standalones apps that will just screw everything up if someone 3 desks over breathes wrong

0 Likes