Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exception "Invalid part tag"

Status
Not open for further replies.

mikaso

Mechanical
Apr 14, 2006
4
Hi all,
I wanted to write some function which starts with opening of part then it do somethink and finish with SaveAs. But during SaveAs method I recieve for some parts exception with meassage "Invalid part tag", errorcode is 641018. I don't have any idea what does it mean [surprise]

Code:
foreach (string path in partlist)
{
try
{
session.ListingWindow.WriteLine(System.DateTime.UtcNow.ToShortTimeString() + @": " + partlist.IndexOf(path) + @" : " + System.IO.Path.GetFileName(path));
dp = session.Parts.Open(path, out pls);
dp.SaveAs(conf.TargetPath + @"\" + System.IO.Path.GetFileName(path));
}
catch (Exception e)
{
session.ListingWindow.WriteLine(e.Message);

}
finally
{
if (dp != null)
{
dp.Close(BasePart.CloseWholeTree.True, BasePart.CloseModified.CloseModified, null);
}
}
}
 
Replies continue below

Recommended for you

Dear Suresh, I checked it. If I try to open part by hand and make SaveAs it works fine. I checked with debugger if I have Tag for part and for session. I think that problem could be somewhere else. I want to use this function to break family members. But I didn't find any different way how to do it, only this SaveAs operation. What is strange that it appears only with few parts.
 
Well, I solved it myself:
Code:
foreach (string path in partlist)
            {
                try
                {
                    session.ListingWindow.WriteLine(System.DateTime.UtcNow.ToShortTimeString() + @": " + partlist.IndexOf(path) + @" : " + System.IO.Path.GetFileName(path));
                    dp = session.Parts.Open(path, out pls);                
                    dp.SaveAs(conf.TargetPath + @"\" + System.IO.Path.GetFileName(path));
                }
                catch (Exception e)
                {
                    session.ListingWindow.WriteLine(e.Message);
                    [b]dp.Close(BasePart.CloseWholeTree.True, BasePart.CloseModified.CloseModified, null);
                    dp = session.Parts.OpenDisplay(path, out pls);
                    dp.SaveAs(conf.TargetPath + @"\" + System.IO.Path.GetFileName(path));[/b] 
                }
                finally
                {
                    if (dp != null)
                    {
                        dp.Close(BasePart.CloseWholeTree.True, BasePart.CloseModified.CloseModified, null);
                    }
                }
In the case exception appears I close part and open it again and display. Then I call SaveAs and it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor