Need suggestions for better performance

Need suggestions for better performance

fourholesn1
Enthusiast Enthusiast
459 Views
4 Replies
Message 1 of 5

Need suggestions for better performance

fourholesn1
Enthusiast
Enthusiast
I am writing a program to go through a folder of parts and change the Part Number iProperty of each one, if required. The program works but is slow and requires a whole bunch of "yes" click because it keeps asking if I want to save. I have Silent Mode on. The entire sub is attached but here is the main part. Can anyone suggest improvements? Thanks - Scott

For Each oInvFile In NewFolder.Files
sExt = LCase(Mid(oInvFile.ShortName, nStr(oInvFile.ShortName, ".") + 1))
If sExt = "ipt" Or sExt = "iam" Then
Set oDoc = oInvApp.Documents.Open(oInvFile.Path)
Set oPNProp = oDoc.PropertySets(3).ItemByPropId(kPartNumberDesignTrackingProperties)
CurPN = oPNProp.Value
Debug.Print oInvFile.Name
Debug.Print CurPN
If InStr(CurPN, "347202") > 0 Then
oPNProp.Value = Replace(CurPN, "347202", SONum)
Debug.Print oPNProp.Value
End If
oDoc.Save
oDoc.Close
End If
Next
0 Likes
460 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

I think that if you change
the line

 

   
face="Courier New">oDoc.Close

 

to

 

   
face="Courier New">oDoc.Close True

 

it will skip the save dialog.




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 3 of 5

fourholesn1
Enthusiast
Enthusiast
Brian, thanks for the suggestion but it didn't help. I notice that the saves are only on assemblies and some of message boxes say this:
"Changes have been made to some assembly components since this assembly was last saved..."
Isn't there a way to do this without opening and closing each model? Would it be better to just open the main assembly and then modify all the occurrances? Also, Inventor is crashing everytime I run this too.
0 Likes
Message 4 of 5

Anonymous
Not applicable
If you are only adjusting the iProperties, you could use the
"FlushToFile"-methode

This is from the help-file:

If you're using Apprentice to access the document properties, and that's the
only edit you've made to the document, you don't need to use the FileSaveAs
object to save the file, but can use the FlushToFile method of the
PropertySets object to save the property changes. This is much more
efficient because it only writes the properties to the document and doesn't
write the entire document.

--
T. Ham
Mechanical Engineer
CDS Engineering BV

Dual Pentium XEON 2.2 Ghz
2 GB SDRAM
NVIDIA QUADRO4 700 XGL (Driver = 77.18)
18 GB SEAGATE SCSI Hard Disc
3Com Gigabit NIC

Windows 2000 Professional SP4
Autodesk Inventor Series 9 SP4
Autodesk Inventor Series 10 SP3a
--
0 Likes
Message 5 of 5

fourholesn1
Enthusiast
Enthusiast
Thanks for the tip Teun, that is what I was looking for. I couldn't find it because it's only in Apprentice.

I got rid of the "Changes have been made to some assembly components since this assembly was last saved..." message by selecting the Prompt button and then Never Prompt Again. It's working pretty well now!
0 Likes