Ilogic get properties from drawing

Ilogic get properties from drawing

goran.nilssonRSJCU
Participant Participant
1,488 Views
2 Replies
Message 1 of 3

Ilogic get properties from drawing

goran.nilssonRSJCU
Participant
Participant

Hello

 

I have an ilogic code that iterate through an assembly document and checks if vault state is "CHANGE ORDER" or not. 

Then I want to access one property at drawings which have state "CHANGE ORDER" but I can't find out a code to access the drawing properties when I'm run Ilogic code from assembly document. The code below don't access drawing prioperties. Does anyone know how to write a code that works?

 

For Each docFile In openDoc.AllReferencedDocuments 
If docFile.DocumentType = 12290 or docFile.DocumentType = 12291 Then
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1) 
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
Dim mVltCon As VDF.Vault.Currency.Connections.Connection
mVltCon = VB.ConnectionManager.Instance.Connection
If mVltCon Is Nothing Then
MessageBox.Show("Not Logged In to Vault! - Login first and repeat executing this rule.")
Exit Sub
End If
Dim VaultPath As String = docFile.FullFileName 
VaultPath = VaultPath.Replace("C:\Vault Workspace\", "$/") 'flip the slashes
VaultPath = VaultPath.Replace("\", "/")
Dim VaultPaths() As String = New String() {VaultPath}

Dim wsFiels() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)

Dim mFileIt As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(conn,wsFiels(0))
Dim lifeCycleInfo As VDF.Vault.Currency.Entities.FileLifecycleInfo = mFileIt.LifecycleInfo

If lifeCycleInfo.StateName = "ÄNDRINGS ORDER" 
no = no + 1
oFile = txtfile
oAppend = IO.File.AppendText(oFile)
desc = iProperties.Value(docFName, "Summary", "Title")
'*****************
drwFName = Left(docFile.FullFileName, (Len(docFile.FullFileName) -3)) & "idw"
oDrawDoc = ThisApplication.Documents.Open(drwFName, True)
revNote = "Ingen info"
drwName= Left(docFile.DisplayName, (Len(docFile.DisplayName) -3)) & "idw"
revNote = iProperties.Value(drwFName, "Summary", "Comments") 
'***************
oAppend.WriteLine(docFile.DisplayName & " " & desc & " " & lifeCycleInfo.StateName & " " & revNote)
oAppend.Flush()
oAppend.Close()
Else
End If
End If

Next

0 Likes
Accepted solutions (1)
1,489 Views
2 Replies
Replies (2)
Message 2 of 3

JhoelForshav
Mentor
Mentor
Accepted solution

Hi Göran!

Would this work for you? 🙂

 

For Each docFile In openDoc.AllReferencedDocuments 
If docFile.DocumentType = 12290 Or docFile.DocumentType = 12291 Then
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1) 
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
Dim mVltCon As VDF.Vault.Currency.Connections.Connection
mVltCon = VB.ConnectionManager.Instance.Connection
If mVltCon Is Nothing Then
MessageBox.Show("Not Logged In to Vault! - Login first and repeat executing this rule.")
Exit Sub
End If
Dim VaultPath As String = docFile.FullFileName 
VaultPath = VaultPath.Replace("C:\Vault Workspace\", "$/") 'flip the slashes
VaultPath = VaultPath.Replace("\", "/")
Dim VaultPaths() As String = New String() {VaultPath}

Dim wsFiels() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)

Dim mFileIt As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(conn,wsFiels(0))
Dim lifeCycleInfo As VDF.Vault.Currency.Entities.FileLifecycleInfo = mFileIt.LifecycleInfo

If lifeCycleInfo.StateName = "ÄNDRINGS ORDER" 
no = no + 1
oFile = txtfile
oAppend = IO.File.AppendText(oFile)
desc = iProperties.Value(docFName, "Summary", "Title")
'*****************
drwFName = Left(docFile.FullFileName, (Len(docFile.FullFileName) -3)) & "idw"
Dim revNote As String = "Ingen info"

Try
oDrawDoc = ThisApplication.Documents.Open(drwFName, False) 'Öppna ritningen osynligt om den finns
revNote = oDrawDoc.PropertySets.Item("Inventor Summary Information").Item("Comments").Value 'Använd nyligen öppnad ritning för att läsa ut Comments
oDrawDoc.Close 'Stäng den osynligt öppnade ritningen så den inte ligger kvar i Inventors minne
Catch
End Try

'***************
oAppend.WriteLine(docFile.DisplayName & " " & desc & " " & lifeCycleInfo.StateName & " " & revNote)
oAppend.Flush()
oAppend.Close()
Else
End If
End If

Next
Message 3 of 3

goran.nilssonRSJCU
Participant
Participant

Hi Jhoel

 

Thanks! It worked well!

 

/Göran

0 Likes