Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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?
Solved! Go to Solution.