Ilogic - docfile = ThisDoc. spcified file name/path

Ilogic - docfile = ThisDoc. spcified file name/path

dfitting
Contributor Contributor
2,679 Views
1 Reply
Message 1 of 2

Ilogic - docfile = ThisDoc. spcified file name/path

dfitting
Contributor
Contributor

Hi,

 

I have a rule that I am working on that bounces off an excel file that generates drawing numbers. It works great except I have an issue when .ipn files are placed in the .idw as the 1st model reference. 

 

I have an if statement that detemines if the model refence is an ipn, and if it is it is needing to change the document to the iam.

 

 

SyntaxEditor Code Snippet

'Look at the model file referenced in the open document
Dim docFile As Document
If ThisDoc.ModelDocument IsNot Nothing Then
docFile = ThisDoc.ModelDocument
Else
MessageBox.Show("This drawing has no model reference", "iLogic")
Return
End If



'format model file name                   
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)   
Dim docFName As String 
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 



Dim IPNTest As String IPNTest = Right(docFName, Len(docFName) - InStrRev(docFName, ".")) If IPNTest = "ipn" docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) LendocFName = InStrRev(docFName, ".", -1) docFName = Left(docFName, Len(docFName) - 3) docFName = docFName & "iam" docFile = ThisDoc.docFName End If

 

 

I have highlighted the line that I am hung up on. I know that I need to convert the file path from a string to a doc file, but I am unsure  how.

 

Note:

The file structures are all as follows:

 

IPNTest.iam -- is the iam that I will be creating custom iproperties. I just need to h

IPNTest.idw -- is the idw where the rule is ran from.

IPNtest.ipn  -- is idw first model reference. 

 

they are all located in the same folder. 

0 Likes
Accepted solutions (1)
2,680 Views
1 Reply
Reply (1)
Message 2 of 2

dfitting
Contributor
Contributor
Accepted solution

I got it figured out using https://forums.autodesk.com/t5/inventor-customization/ilogic-set-open-document-as-active/td-p/567130... as a guide

 

SyntaxEditor Code Snippet

Dim SdocFile As String
    SdocFile = Left(docFile.FullFileName, Len(docFile.FullFileName) - 3)
    
    SdocFile = SdocFile & "iam"
    
    docFile = ThisApplication.Documents.Open(SdocFile,False) 

 

0 Likes