Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

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

Status
Not open for further replies.

lbd7700

Computer
Sep 9, 2011
24
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.
 
Replies continue below

Recommended for you

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)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor