iCAx开思网

标题: 我有一个CATIA二次开发的问题,不知道这里有没有人会呀?请大家多多指教 [打印本页]

作者: tengcomic    时间: 2006-3-9 08:41
标题: 我有一个CATIA二次开发的问题,不知道这里有没有人会呀?请大家多多指教
以下是一个小程序,最后两段就是问题啦,蛮奇怪的,有高手指教吗?
Option Explicit
' COPYRIGHT DASSAULT SYSTEMES 2000

' *****************************************************************************
'   Purpose:       Create A Product Structure document containing
'                        an external component.
'   Assumtions:   Opens CAAPstHull.CATPart in the CATDocView
'   Author:
'   Languages:   VBScript
'   Locales:        English
'   CATIA Level:  V5R6
' *****************************************************************************


Sub CATMain()

    ' -----------------------------------------------------------------------------------------------
    ' Optional: allows to find the sample wherever it's installed
     Dim sDocPath As String
     sDocPath = CATIA.SystemService.Environ("CATDocView")
     If (Not CATIA.FileSystem.FolderExists(sDocPath)) Then
       Err.Raise 9999, , "No Doc Path Defined"
     End If
    ' ------------------------------------------------------------------------------------------------
   
    'Create a new product document object by adding a document with the Product
    'type to the document collection of the CATIA application.
    Dim oProductDoc As Document
    Set oProductDoc = CATIA.Documents.Add("Product")

    'Retrieve the root product.
    Dim oRoot As Product
    Set oRoot = oProductDoc.Product

    'Retrieve the root product collection of products.
    Dim oRootCol As Products
    Set oRootCol = oRoot.Products

    'Open the Part Document
    Dim oPartDoc As Document
    Set oPartDoc = CATIA.Documents.Read("D:\图\1\1\Jin41200.CATProduct")
   

    'Add a new component from the already opened part document.
    Dim oNewComponent As Product
    Set oNewComponent = oRootCol.AddExternalComponent(oPartDoc)
   
    Dim rProduct As Product
    Set rProduct = oNewComponent.Products.Item(1).ReferenceProduct
   
    Dim MyProduct As Product
    Set MyProduct = oRootCol.AddNewComponent("Product", "111")
   
'-----------------------下面两段改名字没反应,改不动,我试过树型里第一层以下的名称都改不动---------------------------------
    Dim MyNewProduct As Product
    Set MyNewProduct = oNewComponent.Products.AddComponent(rProduct)
    MyNewProduct.Name = "444"
   
    Set MyNewProduct = MyProduct.Products.AddNewProduct("222")
    MyNewProduct.Name = "333"
   
   
End Sub

我加上Update也没用,Name付值后值没变,晕死
Save过后也没用,打开一张手工做好的图用编个程序改名称也不行(改一层以下的名称哈)




欢迎光临 iCAx开思网 (https://www.icax.org/) Powered by Discuz! X3.3