Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to check missing parameter and add those in both part and product.

Status
Not open for further replies.

L2S512

Aerospace
Joined
Nov 20, 2013
Messages
9
Location
GB
Hi I'm new to programming, and sorry for stupid questions.

I am trying to make a macro including functions below:

Exactly I got several types of parameters and I want to check they are in every part and product in my CATIA module. If some of them are miss, they would be added in.

please anyone can help me.

Thanks
L
 
Hi Ferdo

Option Explicit

Public Sub CATMain()

'CATMain requires the user to have selected a Product item from the tree
'1. Going to make a list of parts and products
'2. a) Evaluate each one to see if it is missing any parameters
'2. b) Generate any missing parameters


Dim prdTest As Product
Set prdTest = CATIA.ActiveDocument.Selection.Item(1).Value

GetSubProducts prdTest
checkmissingprameter prdTest


End Sub

Public Function GetSubProducts(prdInput As Product) As Collection

'Makes a list of all the sub parts and products within prdInput

Dim i As Integer

Dim prdChild As Product
Dim prtChild As Part

Set GetSubProducts = New Collection

For i = 1 To prdInput.Products.Count
Set prdChild = prdInput.Products.Item(i)

Next i


End Function



This is what I've done right now.
Then I want to create something like a parameter database including some parameter I want to check.
and then add missing parameters.
 
Hi Ferdo

I've updated it, but I dont know how to make "check" function.

any tips?


Option Explicit

Public Sub CATMain()

'CATMain requires the user to have selected a Product item from the tree
'1. Going to make a list of parts and products
'2. a) Evaluate each one to see if it is missing any parameters
'2. b) Generate any missing parameters


Dim prdTest As Product
Set prdTest = CATIA.ActiveDocument.Selection.Item(1).Value

GetSubProducts prdTest
checkmissingparameter prdTest


End Sub

Public Function GetSubProducts(prdInput As Product) As Collection

'Makes a list of all the sub parts and products within prdInput

Dim i As Integer

Dim prdChild As Product
Dim prtChild As Part

Set GetSubProducts = New Collection

For i = 1 To prdInput.Products.Count
Set prdChild = prdInput.Products.Item(i)

Next i


End Function

Public Function checkmissingparameter()

Dim parameters1 As Parameters
Set parameters1 = product1.UserRefProperties

Dim strparam1 As strparam
Dim strparam2 As strparam
Dim strparam3 As strparam
Dim strparam4 As strparam
Dim strparam5 As strparam
Dim strparam6 As strparam
Dim strparam7 As strparam
Dim strparam8 As strparam
Dim strparam9 As strparam

Set strparam1 = parameters1.CreateString("A", "")
Set strparam2 = parameters1.CreateString("B", "")
Set strparam3 = parameters1.CreateString("C", "")
Set strparam4 = parameters1.CreateString("D", "")
Set strparam5 = parameters1.CreateString("E", "")
Set strparam6 = parameters1.CreateString("F", "")
Set strparam7 = parameters1.CreateString("G", "")
Set strparam8 = parameters1.CreateString("H", "")
Set strparam9 = parameters1.CreateString("I", "")

End Function




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top