Creo VB api kullanarak Family table üzerinden yerdeğiştirme

creo-homepage-banner[1]

C.prt isimli part dosyasını A assembly sinin içerisinde  kendi family table instance ile değiştirilebilmesi için aşağıdaki kodları kullanabilirsiniz.



Dim asyncConnection As IpfcAsyncConnection
Dim cAC As CCpfcAsyncConnection
Dim session As IpfcBaseSession
Dim model1 As IpfcModel
Dim model2 As IpfcModel
Dim Assy As IpfcSolid
Dim components As IpfcFeatures
Dim component As IpfcComponentFeat
Dim modelDesc As IpfcModelDescriptor
Dim replaceOperations As CpfcFeatureOperations
Dim Replace As IpfcCompModelReplace
replaceOperations = New CpfcFeatureOperations

cAC = New CCpfcAsyncConnection()
asyncConnection = cAC.Connect(Nothing, Nothing, Nothing, Nothing)
session = asyncConnection.Session
model2 = session.GetModel("C_INST1.PRT", EpfcModelType.EpfcMDL_PART)
model1 = session.GetModel("A.ASM", EpfcModelType.EpfcMDL_ASSEMBLY)
Assy = CType(model1, IpfcAssembly)
components = Assy.ListFeaturesByType(False, EpfcFeatureType.EpfcFEATTYPE_COMPONENT)
For a = 0 To components.Count() - 1
component = components.Item(a)
modelDesc = component.ModelDescr
If modelDesc.InstanceName = "C" Then
Replace = component.CreateReplaceOp(model2)
replaceOperations.Insert(0, Replace)

End If
RichTextBox1.AppendText(modelDesc.InstanceName.ToString() & vbNewLine)
Next
Assy.ExecuteFeatureOps(replaceOperations, Nothing)
asyncConnection.Disconnect(1)


http://www.gokhansaman.com/wp-content/plugins/sociofluid/images/google_48.png http://www.gokhansaman.com/wp-content/plugins/sociofluid/images/myspace_48.png http://www.gokhansaman.com/wp-content/plugins/sociofluid/images/facebook_48.png http://www.gokhansaman.com/wp-content/plugins/sociofluid/images/yahoobuzz_48.png http://www.gokhansaman.com/wp-content/plugins/sociofluid/images/twitter_48.png