×
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

NXOpen Create New revision with VB2010/TC/NX7.5

NXOpen Create New revision with VB2010/TC/NX7.5

NXOpen Create New revision with VB2010/TC/NX7.5

(OP)
Hi, i'm creating a .DLL in VB2010 to use it with File-> Execute-> NXOpen that will do a couple of things, it's a windows form that receives user inputs, mainly part numbers to create and do operations on them, operations like creating new part files in TC, import .dxf files, work with layers, create some curves, extrude, and create assemblies(In case someone needs help with one of the above perhaps i can help). So far i've been able to tackle all the problems i've found either with journaling or the NXOpen .Net API Reference, but this time i can't figure out this one.
The application needs to be able to create either new part files in TC(done) or create new revisions of existing part numbers, this one is the problem right now.

This is how i create the new part files:

******************************************************************
Dim PC_UserName As String = Environment.UserName.ToString
Dim partFromTemplateBuilder1 As PDM.PartFromTemplateBuilder
Dim fileNew1 As FileNew
Dim databaseAttributeManager1 As PDM.DatabaseAttributeManager
Dim nXObject1 As NXObject

partFromTemplateBuilder1 = theSession.Parts.PDMPartManager.NewPartFromTemplateBuilder()

fileNew1 = theSession.Parts.FileNew()

theSession.PdmSession.SetDefaultFolder(PC_UserName.ToString & ":Newstuff")

partFromTemplateBuilder1.CreatePartSpec("Part_DPH",
txt_pcb3d_partNumber.Text.ToString, txt_rev_pcb3d.Text.ToString, "master", "")

databaseAttributeManager1 = partFromTemplateBuilder1.NewDatabaseAttributeManager()

databaseAttributeManager1.SetAttribute("DB_PART_NAME", "X")

databaseAttributeManager1.SetAttribute("DB_PART_DESC", "Y")

databaseAttributeManager1.StoreAttributes()

databaseAttributeManager1.Dispose()

Try
    ' The selected template doesn't exist
    fileNew1.TemplateFileName = ""
Catch ex As NXException
    ex.AssertErrorCode(3815003)
End Try

fileNew1.Application = FileNewApplication.Modeling

fileNew1.Units = Part.Units.Millimeters

fileNew1.NewFileName = "@DB/" & txt_pcb3d_partNumber.Text.ToString & "/" & txt_rev_pcb3d.Text.ToString

fileNew1.MasterFileName = ""

fileNew1.UseBlankTemplate = True

fileNew1.MakeDisplayedPart = True

nXObject1 = fileNew1.Commit()

fileNew1.Destroy()

partFromTemplateBuilder1.Dispose()
******************************************************************

I thought that i could create new part revisions just by giving a higher revision value than the actual, but this results in the error: "Part with given part number exists in the database".

Last thing i tried was the PartFromPartBuilder which states:

******************************************************************
The operation that this builder supports is equivalent to the file save as operation which can:
1.Copy a non-master dataset into a previously existing item revision,
2.Save a master dataset (and possibly non-master datasets) into a new revision of the same item,
3.Save any master or non-master dataset as a completely new item.
******************************************************************

Which i think the point number 2 is the one i'm aiming, but i still can't figure out how to. I can save an existing part as a new item in TC(point 3), but when i try to create a new revision i keep getting the error: "Part with given part number exists in the database".

Can someone tell me if i'm missing something? or this ain't the way to achieve my goal?

Thanks
L.B.D.

RE: NXOpen Create New revision with VB2010/TC/NX7.5

(OP)
Well i think i figured out how to create the revisions in TC, if the part number supplied by the user don't exist in TC i use the code above to create the new part file, but if the part number do exist in TC then i use the code below, and so far i haven't found any problems
  
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim ufs As UF.UFSession
Dim partTag As NXOpen.Tag

ufs = UF.UFSession.GetUFSession

ufs.Part.[New]("@DB/" & txt_sub_partNumber.Text.ToString & "/" & txt_rev_sub.Text.ToString, UF.UFConstants.UF_PART_METRIC, partTag)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

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