iLogic skip readonly files

iLogic skip readonly files

Cosmin_V
Advocate Advocate
749 Views
6 Replies
Message 1 of 7

iLogic skip readonly files

Cosmin_V
Advocate
Advocate

Hi,

I have a rule here that opens, updates, and closes the drawings, it works well so far.
But I would like if someone can help me to finish/complete the rule.
I would like if it is possible when it opens the drawings to skip those that are readonly.
Is that possible?

Many thanks!

 

' ------------Check that the active document is an assembly file------------------------
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
    MessageBox.Show("Please run this rule from the assembly file.", "Drawing update")
    Exit Sub
End If

' ---------------Define the active document As an Assembly file--------------------------
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
Dim oAsmName As String
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4)
'-------------------------------Component Drawings --------------------------------------
'----------------Look at the files referenced by the assembly----------------------------
Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document
'========================================================================================
Dim i As Integer
i = 0
For Each oRefDoc In oRefDocs

                           Dim idwPathName As String
    idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) -3) & "idw"
                           
'-------Check to see that the model has a drawing of the same path and name---------------
    If(System.IO.File.Exists(idwPathName)) Then
     i = i+1   

    End If
Next
 If i = 0 Then 
 MessageBox.Show("No drawings found", "Drawing update", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
  Exit Sub
End If
 If i > 0 Then
Dim Q As Integer
Q = MessageBox.Show("         "& i & " drawings found in this Assembly" & vbCrLf &  "Do you want to Update the checked out drawings?", "Number of Drawings",MessageBoxButtons.OKCancel,MessageBoxIcon.Information)
  If Q = vbCancel Then
    End If
If Q = vbOK Then
                           


'===========================================================================================
' ------------------Work the drawing files for the referenced models------------------------
' -------------This expects that the model has a drawing of the same path and name----------
For Each oRefDoc In oRefDocs
                           
                                                      Dim idwPathName As String
    idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw"
'--------------Check to see that the model has a drawing of the same path and name----------
    If(System.IO.File.Exists(idwPathName)) Then
        Dim oDrawDoc As DrawingDocument
        oDrawDoc = ThisApplication.Documents.Open(idwPathName, True)
                                   oDrawDoc.Update
                                       oDrawDoc.Save
                                         oDrawDoc.Close
       End If
       Next
         End If
           End If
 
0 Likes
750 Views
6 Replies
Replies (6)
Message 2 of 7

bradeneuropeArthur
Mentor
Mentor

with this:

 

	Dim fio As New System.IO.FileInfo(ThisDoc.FileName)
	If fio.IsReadOnly = true Then
		msgbox (fio.FullName)
'YOUR CODE HERE
	End If

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 7

Cosmin_V
Advocate
Advocate

Thanks, but it doesn't work, it opens the readonly files and then this error occurs.

vaida_cosmin_0-1619439265306.png

vaida_cosmin_1-1619439282614.png

 

 

 

0 Likes
Message 4 of 7

bradeneuropeArthur
Mentor
Mentor

you need the option false:

Public Sub main
	
	Dim fio As New System.IO.FileInfo(ThisDoc.FileName)
	If fio.IsReadOnly = False Then
		msgbox (fio.FullName)
	End If
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 7

Cosmin_V
Advocate
Advocate

now is do nothing

0 Likes
Message 6 of 7

bradeneuropeArthur
Mentor
Mentor

Please provide your complete code.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 7

Cosmin_V
Advocate
Advocate

Hello,

here it is...

 

 

Public Sub Main
	
	Dim fio As New System.IO.FileInfo(ThisDoc.FileName)
	If fio.IsReadOnly = False Then
		MsgBox (fio.FullName)



'---------Check that the active Document Is an assembly File------------------------
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
    MessageBox.Show("Please run this rule from the assembly file.", "Drawing update")
    Exit Sub
End If

' ---------------Define the active document As an Assembly file--------------------------
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
Dim oAsmName As String
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4)
'-------------------------------Component Drawings --------------------------------------
'----------------Look at the files referenced by the assembly----------------------------
Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document
'========================================================================================
Dim i As Integer
i = 0
For Each oRefDoc In oRefDocs

                           Dim idwPathName As String
    idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) -3) & "idw"
                           
'-------Check to see that the model has a drawing of the same path and name---------------
    If(System.IO.File.Exists(idwPathName)) Then
     i = i+1   

    End If
Next
 If i = 0 Then 
 MessageBox.Show("No drawings found", "Drawing update", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
  Exit Sub
End If
 If i > 0 Then
Dim Q As Integer
Q = MessageBox.Show("         "& i & " drawings found in this Assembly" & vbCrLf &  "Do you want to Update the checked out drawings?", "Number of Drawings",MessageBoxButtons.OKCancel,MessageBoxIcon.Information)
  If Q = vbCancel Then
    End If
If Q = vbOK Then
                           



'===========================================================================================
' ------------------Work the drawing files for the referenced models------------------------
' -------------This expects that the model has a drawing of the same path and name----------
For Each oRefDoc In oRefDocs
                           
                                                      Dim idwPathName As String
    idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw"
'--------------Check to see that the model has a drawing of the same path and name----------
    If (System.IO.File.Exists(idwPathName)) Then
        Dim oDrawDoc As DrawingDocument
        oDrawDoc = ThisApplication.Documents.Open(idwPathName, True)
                                   oDrawDoc.Update
                                       oDrawDoc.Save
                                         oDrawDoc.Close
       End If
       Next
         End If
           End If
	 	End If
End Sub 

 

0 Likes