×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Exception "Invalid part tag"

Exception "Invalid part tag"

Exception "Invalid part tag"

(OP)
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);
}
}
}

RE: Exception "Invalid part tag"

Make sure when you open the part, the part has opened successfully. Also, you can check before saveas that the tag is not null.

Suresh
www.technisites.com.au

RE: Exception "Invalid part tag"

(OP)
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.

RE: Exception "Invalid part tag"

(OP)
Well, I solved it myself:

CODE --> c#

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);
                    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)); 
                }
                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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources