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!

Sort patterns 1

Status
Not open for further replies.

gerlado

Mechanical
Oct 17, 2012
23
ES
Hello again

Apparently I feel bored with this topic, but I would like to finish my script correctly. I´m sorry

Initially I have a Part, which have some Holes and some Thread, there are also some Rectangullar Pattern and Circular Pattern.

My script can read Holes and Thread, give me your Diameter, also can read number of Rectangular Pattern and Circular Pattern

My problem is when I want to read the copies created by Pattern.

I try sel.search all patterns and in this part aplly itemtocopy, but for me it´s impossible that the script give me any number of item to copy....

someone could show me the way?

Thanks

If necessary I can write the script
 
Replies continue below

Recommended for you

I'm quite poor at this stuff, but you are putting a lot of effort into this, so... Have you tried capturing the number of items that catia has prompted the user to input into the pattern using OLE or the knowledge tool bench? Then you should be able to bypass trying to read the copies created and just use a/the multiplier from the pattern. It's a long shot, but brainstorming doesn't hurt... "much".
 
Hi,

I like when someone is insistent to solve a problem but I don't like when don't read with more attention what others are trying to tell.

In this post lukaszsz told you something about itemtocopy . Did you checked in documentation what does it mean?

And did you tried, really, to understand what he wanted to suggest you? I suppose not quite really....look bellow what he wanted to suggest (code in CATScript, you have to modify to your needs, I've put more message boxes just to show how you can get more information)

Language="VBSCRIPT"

Sub CATMain()

Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = partDocument1.Selection

selection1.Search "CATPrtSearch.Pattern,all"

For i=1 To selection1.Count

msgbox selection1.item(i).value.name

Set objSelected = selection1.Item(1).Value
MsgBox objSelected.Parent.Name
Msgbox objSelected.itemtocopy.name
MsgBox objSelected.Parent.Parent.Name

Next

End Sub

Now, coming to parameters, you can get all parameters in a CATPart with code bellow (again CATScript). If you want only for holes, you have to adapt.

Language="VBSCRIPT"

Sub CATMain()

Dim catDoc As PartDocument
Dim catPart As Part

Set catDoc=CATIA.ActiveDocument
Set catPart=catDoc.Part

Set objParameters = catPart.Parameters

' Loop on parameters to retrieve them
For I = 1 To objParameters.Count
Set objParameter = objParameters.Item(I)
strParmName = objParameter.Name
strParmValue = objParameter.ValueAsString

MsgBox strParmName & " " & strParmValue

Next

End Sub


Regards
Fernando

 
Good night

I understand you message, I´m sorry if I am so heavy with this topic.

I search item to copy in v5automation.chm, and I only find text about how write the word in my script. Also I search item to copy in Visual Basic program VB --> Edit --> Object browser and search pattern, where I find the word parent about item to copy and itemtocopy.name, itemtocopy.parent ...

My problem start when I try to write this reference in my script, I don´t get work it.

I appreciate your script FERDO, but I can not fix my problem, and I really study the code. I guess my knowledge of Visual Basic are basic. Anyway, when I study your Script I find a path that can help me whit this " Number in dir 1" Of rectangular Pattern, and "Angular Number" of Circular Pattern, this words should show me the numbers of copy of my object in any pattern that I search with the script. I only need search the way of write this path in my code

I will work with this far as it goes.

Anyway a lot of thanks for your help, and I´m sorry if seems that I can´t try to learn and study about your messages, I do it because this is a very important thing for me.

Thank you again
 
Hi,

Understood.

Indeed, now you have to search "between lines" how to solve your problem, what you wrote is a good starting point.

If you work with catvba (vba editor) you have to go in Tools-References and tick CATIA libraries that are referring to the workbench that you need (Part design or Product or whatever you need).

My codes are working in CATScript, I didn't test them in catvba, I suppose they are working if you are loading libraries and adapt the language (if necessary).

Regards
Fernando

 
Hi again

I have a few days study caav5. I believe that I am near the solution, but don´t find it yet.

My study:

In circullar pattern, the solution should be:
Properties--> catInstancesandAngularSpacing-->AngularRepartition.InstanceCount.Value

In Rectangular Pattern, te solution shoul be:
Properties-->catInstancesandSpacing--> ?

I try the script:


Sub setinstanceangularspacing()

Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = partDocument1.Selection

selection1.Search "CATPrtSearch.Pattern,all"

Dim i
For i = 1 To selection1.Count

MsgBox selection1.Item(i).Value.Name

Dim objSelected
Dim circularpattern

Set objSelected = selection1.Item(1).Value

'------------
'--->Doesn´t work
'Set circularpattern = selection1.Item(1).Value
'MsgBox CatCircularPatternParameters.catInstancesandAngularSpacing
'----------

'------------
'--->Doesn´t work
'MsgBox objSelected.AngularRepartition.InstanceCount.Value --> Doesn´t work
'----------

'---------
'----> Work but don´t show me the instances copy of my main body
MsgBox catUnequalAngularSpacing
MsgBox catCompleteCrown
MsgBox catInstancesandAngularSpacing




Next

End Sub

Thank if anybody know the solution
Regards
 
then programming in vb
I can not get to know the number of copies to make a pattern?
I believe that this should be instancecount.value....
because in the example of help show this:


***********************************************************************
' Purpose: Changes pattern description
' Assumptions: Looks for CAAPriChangePattern.htm in the DocView
' Author:
' Languages: VBScript
' Locales: English
' CATIA Level: V5R14
' ***********************************************************************

Sub CATMain()

Dim oPartDocument As PartDocument
Dim oPart As Part
Dim oSelection As Selection
Dim InputObjectType(0) As String
Dim oStatus as String
Dim oCircularPattern as CircPattern

' ------------
' Get the part document
' ------------
Set oPartDocument = CATIA.ActiveDocument
' ------------
' Get the part
' ------------
Set oPart = oPartDocument.Part
' ------------
' Get the selection
' ------------
Set oSelection = oPartDocument.Selection
' ------------
' Set the selection type
' ------------
InputObjectType(0) = "CircPattern"
' ------------
' Get the status
' ------------
oStatus = oSelection.SelectElement2 ( InputObjectType, "Select a circular pattern", True )
' ------------
' Get the object in the selection
' ------------
Set oCircularPattern = oSelection.Item(1).Value
' ------------
' Set the circular pattern instance number
' ------------
oCircularPattern.AngularRepartition.InstancesCount.Value = 6

' ------------
' Set the circular pattern instance as Unequal Angular Spacing mode
' ------------
oCircularPattern.CircularPatternParameters = catUnequalAngularSpacing
oCircularPattern.SetUnequalStep 6
' ------------
' Set the circular pattern Unequal Angular Spacing
' ------------
oCircularPattern.SetInstanceAngularSpacing 2, 30.000000
oCircularPattern.SetInstanceAngularSpacing 3, 75.000000
oCircularPattern.SetInstanceAngularSpacing 4, 75.000000
oCircularPattern.SetInstanceAngularSpacing 5, 30.000000
oCircularPattern.SetInstanceAngularSpacing 6, 75.000000
' ------------
' Update the part
' ------------
oPart.Update


End Sub




I thought it was near to the solution..
Thanks

Another topic
I Believe there was a confussion, i have caav5 visual basic help downland to internet, I don´t have a special license, therefore my script is a simple code write in visual basic editor of catia v5 r20


Thanks Ferdo anyway, your help is invaluable
 
Friends

I have it


Sub numberofpattern()


Dim oPartDocument As PartDocument
Dim oPart As Part
Dim oStatus As String
Dim oCircularPattern As CircPattern

Dim TheMeasurable As Measurable
Dim TheSPAWorkbench As Workbench

Dim InputObjectType(0)
InputObjectType(0) = "AnyObject"

Dim oSelection
Set oSelection = CATIA.ActiveDocument.Selection
oSelection.Clear
InputObjectType(0) = "CircPattern"
oStatus = oSelection.SelectElement2(InputObjectType, "Select a circular pattern", True)


Set oCircularPattern = oSelection.Item(1).Value
MsgBox (oCircularPattern.angularrepartition.InstancesCount.Value)

End Sub

Now I have to find the rectangular pattern variable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top