NX二次开发源码分享:创建一个临时的prt文件
主要是一个函数在CFI的头文件下,创建随机文件名
Function CreateNewTemporaryPartQuietly() As Part
Dim theUFSession As UFSession = UFSession.GetUFSession()
Dim nxMan As Boolean = Nothing
theUFSession.UF.IsUgmanagerActive(nxMan)
Dim fileNew1 As FileNew = theSession.Parts.FileNew()
fileNew1.Application = FileNewApplication.Gateway
fileNew1.Units = theSession.Parts.Work.PartUnits
Dim tpn As String = Nothing
theUFSession.Cfi.GetUniqueFilename(tpn)
If (nxMan) Then
fileNew1.NewFileName = "@DB/" & tpn & "/A"
Else
Dim tmp_dir As String = Nothing
theUFSession.UF.TranslateVariable("UGII_TMP_DIR", tmp_dir)
fileNew1.NewFileName = tmp_dir & "\" & tpn
End If
fileNew1.UseBlankTemplate = True
fileNew1.MakeDisplayedPart = False
CreateNewTemporaryPartQuietly = fileNew1.Commit()
fileNew1.Destroy()
End Function
页:
[1]