Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Count Parameter

Status
Not open for further replies.

djmjr

Aerospace
Feb 7, 2014
22
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

 
Replies continue below

Recommended for you

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.
 
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.....
 
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,
 
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
 
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:
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!
 
what about:

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

?

Eric N.
indocti discant et ament meminisse periti
 
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?
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor