最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Instanciate a compartment from the catalog into the current Product in CATIA VBA - Stack Overflow

programmeradmin1浏览0评论

I am trying to instantiate component form the catalog

    Dim catia As Object
    Set catia = GetObject(, "CATIA.Application")
    
    ' Open the main document containing the product
    Dim mainDoc As Document
    Set mainDoc = catia.ActiveDocument
    

   ' Define the compartment ID to get from the catalog
    Dim compartmentID As String
    compartmentID = "FICT-EQ-00002"
    
    ' Get the PspAppFactory interface
    Dim pspFactory As pspAppFactory
    Set pspFactory = mainDoc.product.pspAppFactory
    
    ' Instantiate the compartment into the current product
    Dim compartment As PspGroup
    Set compartment = mainDoc.GetCompartment(mainProduct, compartmentID)

Facing error in this line . Set pspFactory = mainDoc.product.pspAppFactory

any suggestion would be highly appreciable

I am trying to instantiate component form the catalog

    Dim catia As Object
    Set catia = GetObject(, "CATIA.Application")
    
    ' Open the main document containing the product
    Dim mainDoc As Document
    Set mainDoc = catia.ActiveDocument
    

   ' Define the compartment ID to get from the catalog
    Dim compartmentID As String
    compartmentID = "FICT-EQ-00002"
    
    ' Get the PspAppFactory interface
    Dim pspFactory As pspAppFactory
    Set pspFactory = mainDoc.product.pspAppFactory
    
    ' Instantiate the compartment into the current product
    Dim compartment As PspGroup
    Set compartment = mainDoc.GetCompartment(mainProduct, compartmentID)

Facing error in this line . Set pspFactory = mainDoc.product.pspAppFactory

any suggestion would be highly appreciable

Share Improve this question asked Feb 6 at 9:10 charan tejcharan tej 1
Add a comment  | 

1 Answer 1

Reset to default 0

According to the documentation (I haven't tested it), getting the factory needs several steps (example for piping, see also the CatPspIDLApplicationID enumeration in the documentation):

Dim objPspWorkbench As PspWorkbench
Dim objPspApplication As PspApplication
Dim objPspAppFactory As PspAppFactory
Dim objProductRoot As Product

Set objProductRoot = CATIA.ActiveDocument.Product
Set objPspWorkbench = objProductRoot.GetTechnologicalObject("PspWorkbench")
Set objPspPipApplication = objPspWorkbench.GetApplication(catPspIDLCATPiping)
Set objPspPipAppFactory = objPspWorkbench.GetInterface("CATIAPspAppFactory",objPspPipApplication)

You may also have a look onto the samples in the documentation for a proper error handling.

发布评论

评论列表(0)

  1. 暂无评论