2016-11-10 45 views
0

我在CATIA中有一個包含多個CATParts的產品。 我使用DMU Review Creation中的符號Sectioning來創建一個節來切割產品。 這部分被稱爲Section.1。更改產品中3D部分的名稱

我在尋找的是從CATPart 1(myPartNumber1)取名的代碼,並將該部分的名稱從「section.1」更改爲myPartNumber1。

這是我的代碼在vb.NET至今:

Sub x() 

Set productDocument1 = CATIA.ActiveDocument 

myPartNumber1 = productNumber1.Product.Products.Item(1).Name 
Set selection1 = productDocument1.Selection 
selection1.Search("Name='Section.1',all") 
selection1.item(1).value.Name = myPartNumber1 

End Sub 

我在最後一行得到的一個問題。

+0

請直接複製並粘貼您的代碼,而不是插入圖片... StackOverflow可以格式化並突出顯示您的代碼。你有什麼確切的問題?什麼是錯誤? –

回答

0

子CATMain()

Set oprod = CATIA.ActiveDocument.Product 
Set TheSections = oprod.GetTechnologicalObject("Sections") 
Set mySection = CATIA.ActiveDocument.Product.GetTechnologicalObject("Sections") 

Set oSection = oprod.GetTechnologicalObject("Sections") 
Set selectionpart = CATIA.ActiveDocument.selection 

partcount = selectionpart.Count 
    for k = 1 to partcount 
      Set selectionpart = oprod.Products.Item(k) 
    myPartNumber = CATIA.ActiveDocument.Product.Products.Item(k).Name 

    sectioncount = oSection.Count 
    MsgBox sectioncount 
      for i = 1 To sectioncount 
       Set oSection = mySection.item(i) 
       oSection.Name = myPartnumber 
     Next 
    Next 

末次

問題: 我得到的是我所有的部分在產品得到了第一部分的名稱

我需要IST :第一部分得到第一個PArt的名稱,第二部分得到第二部分的名稱...

我明顯寫了一些東西我的循環錯了。

THX