NX Journal モデルを新規作成

モデルを新規作成するプログラムを作成しました。

import NXOpen
import NXOpen.PDM
 
def main():
 
    theSession  = NXOpen.Session.GetSession()
 
    fileNew1 = theSession.Parts.FileNew()
    fileNew1.TemplateFileName = "_TemplateFileName_"
    fileNew1.UseBlankTemplate = False
    fileNew1.ApplicationName = "ModelTemplate"
    fileNew1.Units = NXOpen.Part.Units.Millimeters
    fileNew1.RelationType = "master"
    fileNew1.UsesMasterModel = "No"
    fileNew1.TemplateType = NXOpen.FileNewTemplateType.Item
    fileNew1.TemplatePresentationName = "_TemplatePresentationName_"
    fileNew1.ItemType = "Item"
    fileNew1.Specialization = ""
    fileNew1.SetCanCreateAltrep(False)
    fileNew1.MasterFileName = ""
    fileNew1.MakeDisplayedPart = True
    fileNew1.DisplayPartOption = NXOpen.DisplayPartOption.AllowAdditional
 
    partOperationCreateBuilder1 = theSession.PdmSession.CreateCreateOperationBuilder(NXOpen.PDM.PartOperationBuilder.OperationType.Create)
    partOperationCreateBuilder1.SetOperationSubType(NXOpen.PDM.PartOperationCreateBuilder.OperationSubType.FromTemplate)
    partOperationCreateBuilder1.SetModelType("master")
    partOperationCreateBuilder1.SetItemType("Item")
    partOperationCreateBuilder1.DefaultDestinationFolder = ":Newstuff"
    partOperationCreateBuilder1.SetOperationSubType(NXOpen.PDM.PartOperationCreateBuilder.OperationSubType.FromTemplate)
    partOperationCreateBuilder1.ValidateLogicalObjectsToCommit()
    partOperationCreateBuilder1.CreateSpecificationsForLogicalObjects( [partOperationCreateBuilder1.CreateLogicalObjects()] )
 
    fileNew1.SetPartOperationCreateBuilder(partOperationCreateBuilder1)
 
    fileNew1.Destroy()
    theSession.ApplicationSwitchImmediate("UG_APP_MODELING")
 
if __name__ == '__main__':
    main()

コメント

タイトルとURLをコピーしました