×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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

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

(OP)
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.

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

(OP)
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




Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources