Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hello,
There is an example code using JLINK available here: https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS153609&art_lang=en&posno=1&q=vb%20api%20assembly%20save%20as&…
But I am looking for the VB.net version. especially the VB.net version of the following portion:
in VB API, "model.Backup" does not seem to work correctly, and "model.copy/copyandretrieve" don't include the part files.
Model model = session.RetrieveModelWithOpts(modelDescriptor, pfcSession.RetrieveModelOptions_Create());
ModelDescriptor md = model.GetDescr();
is there an equivalent to "GetDescr()" in VB API?
Does "model.Backup(...)" works correctly in your VB.net code?
Stephane
Solved! Go to Solution.
For those who Need to do the same thing using VB.net, here is my solution:
Imports pfcls
Imports System
Module Module1
Sub Main()
Dim connection As IpfcAsyncConnection
Dim cac As New CCpfcAsyncConnection
Dim session As IpfcBaseSession
Dim template As IpfcModel
Dim path As String
Dim descModel As IpfcModelDescriptor
Dim opt As IpfcRetrieveModelOptions
Dim Modi As IpfcModelDescriptor
Dim win As IpfcWindow
'Dim descModelCreate As CCpfcModelDescriptor
path = "C:\ptc\Creo_2.0\Parametric\bin\parametric.exe"
Try
'Start a new Creo Session
connection = cac.Start(path, ".")
session = connection.Session()
session.ChangeDirectory("C:\work4\model\")
session.LoadConfigFile("M:\PRO_E\Creo\configs\config.pro")
connection.EventProcess()
session.AuthenticateBrowser("******", "*****")
System.Threading.Thread.Sleep(5000)
'Open and display the template assembly model located in M:\ drive
opt = (New CCpfcRetrieveModelOptions).Create()
opt.AskUserAboutReps = False
descModel = (New CCpfcModelDescriptor).CreateFromFileName("axialcasing.asm")
descModel.Path = "M:\PRO_E\Creo\start_files\templates\07_Exhaust_Casing_3D_models\Type1\"
template = session.RetrieveModelWithOpts(descModel, opt)
win = session.GetModelWindow(template)
template.Display()
Modi = template.Descr()
Modi.Path = "C:\work4\model"
template.Backup(Modi)
connection.Disconnect(DBNull.Value)
Catch ex As Exception
MsgBox("problem")
End Try
End Sub
End Module
For those who Need to do the same thing using VB.net, here is my solution:
Imports pfcls
Imports System
Module Module1
Sub Main()
Dim connection As IpfcAsyncConnection
Dim cac As New CCpfcAsyncConnection
Dim session As IpfcBaseSession
Dim template As IpfcModel
Dim path As String
Dim descModel As IpfcModelDescriptor
Dim opt As IpfcRetrieveModelOptions
Dim Modi As IpfcModelDescriptor
Dim win As IpfcWindow
'Dim descModelCreate As CCpfcModelDescriptor
path = "C:\ptc\Creo_2.0\Parametric\bin\parametric.exe"
Try
'Start a new Creo Session
connection = cac.Start(path, ".")
session = connection.Session()
session.ChangeDirectory("C:\work4\model\")
session.LoadConfigFile("M:\PRO_E\Creo\configs\config.pro")
connection.EventProcess()
session.AuthenticateBrowser("******", "*****")
System.Threading.Thread.Sleep(5000)
'Open and display the template assembly model located in M:\ drive
opt = (New CCpfcRetrieveModelOptions).Create()
opt.AskUserAboutReps = False
descModel = (New CCpfcModelDescriptor).CreateFromFileName("axialcasing.asm")
descModel.Path = "M:\PRO_E\Creo\start_files\templates\07_Exhaust_Casing_3D_models\Type1\"
template = session.RetrieveModelWithOpts(descModel, opt)
win = session.GetModelWindow(template)
template.Display()
Modi = template.Descr()
Modi.Path = "C:\work4\model"
template.Backup(Modi)
connection.Disconnect(DBNull.Value)
Catch ex As Exception
MsgBox("problem")
End Try
End Sub
End Module