IProperties filled in by Excel

IProperties filled in by Excel

Anonymous
Not applicable
495 Views
9 Replies
Message 1 of 10

IProperties filled in by Excel

Anonymous
Not applicable
I have approx 8,000 MDT5 drawings that I need to migrate to IV
10. I need to fill in the Iproperties on the corresponding *.ipt *.iam
and *.idw for the drawing number. All the information I need to fill
in will come from the BOM in MDT that I have exported to Excel spread
sheets. I have been trying to figure out how to do this thru VBA but I
have yet to figure this out. I just started learning VBA two days ago
and have been searching the newsgroups for procedures on how to do
this any help would be very much appreciated.

TIA
0 Likes
496 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable
Hi Lee,

We have this exact application built. If you would like more information
please feel free to give me a call.

Kevin Degabriele
Netstream Solutions
905-970-1827



"Lee Brown" wrote in message
news:5089945@discussion.autodesk.com...
I have approx 8,000 MDT5 drawings that I need to migrate to IV
10. I need to fill in the Iproperties on the corresponding *.ipt *.iam
and *.idw for the drawing number. All the information I need to fill
in will come from the BOM in MDT that I have exported to Excel spread
sheets. I have been trying to figure out how to do this thru VBA but I
have yet to figure this out. I just started learning VBA two days ago
and have been searching the newsgroups for procedures on how to do
this any help would be very much appreciated.

TIA
0 Likes
Message 3 of 10

Anonymous
Not applicable
Lee,

What you are looking for is most certainly possible with VB and the code necessary for such a action is almost entirely available on this newsgroup.

For importing excel values to iproperties see:
http://discussion.autodesk.com/thread.jspa?messageID=4947665

On this moment I can only give you some leads, for proper advice I have got to have some code or a precise description of the function and excel file.

Good luck,
Matthijs
0 Likes
Message 4 of 10

Anonymous
Not applicable
I open the link and there is no code there!

wrote in message news:5090188@discussion.autodesk.com...
Lee,

What you are looking for is most certainly possible with VB and the code
necessary for such a action is almost entirely available on this newsgroup.

For importing excel values to iproperties see:
http://discussion.autodesk.com/thread.jspa?messageID=4947665

On this moment I can only give you some leads, for proper advice I have got
to have some code or a precise description of the function and excel file.

Good luck,
Matthijs
0 Likes
Message 5 of 10

Anonymous
Not applicable
Sorry,

It ain't my post, just something I found in a quick search in the groups. Do you have any code or idea where to you want to go? Just like I said earlier, it is a bit hard to shoot some code when I don't know what you got and what it is supposed to do.

Matthijs
0 Likes
Message 6 of 10

Anonymous
Not applicable
Lee,

Here is some code I think you will find useful. It is something I once found and edited a bit for your purpose. You will find it need some tweaking, but basically it does the job. It reads from the enclosed xls file.
Let me know if it works.

Mattijs van Lunsen
Tebulo Engeneering, Holland

Option Explicit

Public Sub CopyProperty()

' Leg een verbinding met het Inventor document
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

' Open the proper Excel file
Dim oXls As Excel.Application
Set oXls = CreateObject("Excel.Application")
Dim oSheet As Excel.WorkSheet
Set oSheet = oXls.Workbooks.Open("D:\MDT5 Properties.xls").ActiveSheet

' Using the Inventor document name as a reference
Dim sPath As String
Dim oRow As Integer
Dim oColumn As Integer
oRow = 1
oColumn = 1
sPath = Left(oDoc.DisplayName, Len(oDoc.DisplayName) - 4)
Do While Not oSheet.Cells(oRow, 1) = sPath
oRow = oRow + 1
Loop

Dim sProperty As String
Dim sValue As String
Do While Not oSheet.Cells(1, oColumn) = ""
On Error Resume Next
sProperty = oSheet.Cells(1, oColumn)
sValue = oSheet.Cells(oRow, oColumn)
' Next line will crash if property already excists, solved by error trapping
Call oDoc.PropertySets("User Defined Properties").Add(sValue, sProperty)
If Err 0 Then
Err.Clear
oDoc.PropertySets("User Defined Properties").Item(sProperty).Delete
Call oDoc.PropertySets("User Defined Properties").Add(sValue, sProperty)
End If
oColumn = oColumn + 1
Loop

' Do not remove, if not present Excel will still be running
oXls.Quit
Set oSheet = Nothing
Set oXls = Nothing

End Sub
0 Likes
Message 7 of 10

Anonymous
Not applicable
Thank you for your responses Chris you have to enable macros for the
excel macro to work correctly. This will partially work but I would
like to add a custom property as blank size which I have not figured
out yet.

mvunsen I get an error when I run your script I am rather new to VBA
and don't understand alot of what I get as a response. I put the
workbook on my D:\ drive and I am using this with Excel 2000 which Im
thinking may be a conflict in the call to excel.
0 Likes
Message 8 of 10

Anonymous
Not applicable
 
0 Likes
Message 9 of 10

Anonymous
Not applicable

You need to reference the Excel type library in
the VB project.




Brian R.
Iwaskewycz


style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">CAD Systems
Manager


style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">
href="http://www.corefurnace.com">Core Furnace Systems

0 Likes
Message 10 of 10

Anonymous
Not applicable
I would like to add a Custom property called BLANK I have found this
code in the help file but I am not sure where to add BLANK at. If this
is successful will BLANK be picked up as a property when I access the
properties.

I was also trying to load Apprentice Server but I get an error saying
inventor is already loaded is there any way to bypass this check for
existing versions and load it anyway.


'declare new PropertySet object to be added
Dim oNewPropertySet As PropertySet

On Error Resume Next
' Try to obtain the PropertySet to see if it already exists
Set oNewPropertySet = oPropsets.Item("New PropertySet")

' If PropertySet does not exist then add the new PropertySet
If Err Then
' Add the new PropertySet
Set oNewPropertySet = oPropsets.Add("New PropertySet")

' Adding the new Property to the new PropertySet
Call oNewPropertySet.Add("A Value", "New Property", 2)
End If
0 Likes