How to add drawing iproperties from an excel?

How to add drawing iproperties from an excel?

shuaib_cad
Advocate Advocate
1,004 Views
8 Replies
Message 1 of 9

How to add drawing iproperties from an excel?

shuaib_cad
Advocate
Advocate

I have a requirement to add iproperties (checked by, checked date, design state, etc.) for a list of drawings.

I want to add these iproperties in Inventor from an excel using vba macros.

 

Please help me to create an excel vab macro to control Inventor and perform the above operations automatically.

 

 

Regards,

Mohammed Shuaib K

Accepted solutions (1)
1,005 Views
8 Replies
Replies (8)
Message 2 of 9

Michael.Navara
Advisor
Advisor
Accepted solution

For this task is better to start from Excel VBA. You can add reference to "Inventor Object Library" and then you can use Inventor.ApprenticeServer for writing data to iProperties. Apprentice has the best performance for this tasks.

 

Excel VBA example:

 

Sub WriteData()
    Dim appServer As Inventor.ApprenticeServerComponent
    Set appServer = New ApprenticeServerComponent
    
    Dim oSheet As Worksheet
    Set oSheet = ThisWorkbook.ActiveSheet
    
    For i = 2 To 3
        
        Dim file As String
        Dim checkedBy As String
        Dim checkedDate As Date
        
        file = oSheet.Range("A" & i).Value
        checkedBy = oSheet.Range("B" & i).Value
        checkedDate = oSheet.Range("C" & i).Value
        
        Dim invDoc As Inventor.ApprenticeServerDocument
        Set invDoc = appServer.Open(file)
        
        invDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Checked By").Value = checkedBy
        invDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Date Checked").Value = checkedDate
        
        invDoc.PropertySets.FlushToFile
        invDoc.Close
        
    Next
    
End Sub

 

Test data preview:

Test data previewTest data preview

Add reference to Inventor in Excel VBA

2020-12-05_11-34-13.png

 

 

 

Message 3 of 9

shuaib_cad
Advocate
Advocate

shuaib_cad_0-1607201265021.png

 

0 Likes
Message 4 of 9

shuaib_cad
Advocate
Advocate

Getting the above error while running the code?

Please help me fix this issue.

0 Likes
Message 5 of 9

Michael.Navara
Advisor
Advisor

I don't know what error you get. My code works, but omits error handling for clarity.

  • You need registered Inventor correctly.
  • Opened file must exists.
  • Opened file can't be newer then registered Inventor
0 Likes
Message 6 of 9

JonnyPot
Advocate
Advocate

hello @Michael.Navara 
could you tell me where is the VBA Project - References tab is located. thank you

0 Likes
Message 7 of 9

Michael.Navara
Advisor
Advisor

Full example is in attachment. Extract files to C:\Temp\*.*

Open "Data.xlsm" and included VBA project.

References tab is located here:

2020-12-07_11-38-51.png

 

Message 8 of 9

JonnyPot
Advocate
Advocate

Thank you 👍

0 Likes
Message 9 of 9

quangnguyen2FWX7
Participant
Participant

Hi Bro,

When i want to change from "checked by" to other one or use custome properties, how can i do?

Many thank

0 Likes