×
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

Count Parameter

Count Parameter

Count Parameter

(OP)
Hi,

I'm trying to find a way to create a parameter that will count the number of like catparts within a catproduct. What I am trying to do is to create an "Attribute Link" within a text box that will display this number of each sub-detail within a weldment.

I haven't had much luck in searching. Any help will be appreciated.

Thanks!!

Dennis

RE: Count Parameter

Should just be a simple For Next loop that searches for given part name and adds 1 every time it encounters it. Then you can assign the value of the desired name and input into a text box or whatever. Can't think of the code off the top of my head, but I'll see if I can get an example for you.

RE: Count Parameter

(OP)
Attached is of what I have so far.

I want the quantity (highlighted) to linked to a parameter. I was thinking it could be an Integer parameter. But I don't know if there is a simple formula that counts the catparts.

Can you put a "Next Loop" as a formula in a parameter?

No idea why the picture isn't sticking with the post.....

RE: Count Parameter

No attachment.

Also, I don't think a parameter will work the way you're intending it to. Might have to use macro instead... I'm not an expert though, someone chime in and give us some knowledge.

If you choose to go macro, you're going to get the For Next loop from 1 to the total number of parts/products. At each interval, the loop will check your input name to the name of the part/product and act accordingly.

Again, give me some time, I'll see if I can write up some example for you.

Cheers,

RE: Count Parameter

you can play with Knowledgeware and build a BOM using .Children and list size like Product.Query("Part","x.Name==\"Part1\").Size()... but a quick script might be easier

Eric N.
indocti discant et ament meminisse periti

RE: Count Parameter

Yeah, I was going to suggest using the BOM feature to count everything. I don't really like the BOM feature in CATIA though...

@djmjr
I don't have a good answer for you at the moment. I'm working on a small piece of code for you but can't figure out one thing...

I'll post anyway as it might lead you in the right direction. Maybe someone else can solve the issue.

CODE --> CATVBS

Option Explicit 'forces variable declaration

Sub CATMain()

dim partDocument, product, selection, status, filter(0), selCount, name

set partDocument = CATIA.ActiveDocument
set product = partDocument.Product
set selection = partDocument.Selection

partName = Inputbox("test1", "test2", "test3") 'input name to be searched

selection.Search("Name=partName, all")

selCount = selection.Count

End Sub 

The issue here is line "selection.Search("Name=partName, all")". I want to use my input value "partName" as the search field but it doesn't work. I'll see if I can do some more digging around.

Good luck!

RE: Count Parameter

what about:

StrToSearch = "Name=" + partName + ", all"
selection.Search(StrToSearch)

?

Eric N.
indocti discant et ament meminisse periti

RE: Count Parameter

(OP)
Thanks guys for the help and information. I appreciate it, I really do.

I like the macro idea, but in this instance I don't think it will be something I would use since I am generating a BOM with the Bill of Material function, so it isn't like the quantities won't be there for the guys processing material down the line. I was just trying to find a way that was automated that I would show within my captures, at the detail level, this information (qty, size, material type) is shown.

Can a macro be made to do the follwing?

1. Initiates Axonometric View
2. Prompts user to make selection on screen
3. Issues the create text command
4. Prompt user to make selection on screen
5. Fills in text box with the information I'm looking for above.

I'm not asking for one to be developed, I may take a crack at trying to do that myself, once I learn more about this macro and catvbs. I just want to know if its possible?

RE: Count Parameter

VBA could do that. Make sure you search your v5automation.chm file to get familiar with CATIA object structure and API. look into the many example you can find into this file also.

Eric N.
indocti discant et ament meminisse periti

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