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!

Macro to obtain the limit planes of a pad 2

Status
Not open for further replies.

TiagoFigueiredo

Industrial
May 22, 2013
494
PT
I'm trying to find the limit planes of a pad by a macro.

Capture_i9emor.png


In this case by selec the pad, I want that my macro gives me that the limites are Plane.1 and Plane.2

Tiago Figueiredo
Tooling Engineer
 
Replies continue below

Recommended for you

Hi

Code:
Sub CATMain()

Dim varSelection As Variant
Set varSelection = CATIA.ActiveDocument.Selection
    
Dim InputFilter(0) As Variant
InputFilter(0) = "Pad"
    
Dim SelStatus As String
SelStatus = varSelection.SelectElement2(InputFilter, "Select Pad object", True)
    
Dim objPad As Pad
Dim objFirstLimit As Limit
Dim dblFirstLimit As Double
    
If (SelStatus = "Normal") Then
        
    Set objPad = varSelection.Item2(1).Value
    Set objFirstLimit = objPad.FirstLimit
    dblFirstLimit = objFirstLimit.Dimension.Value
    MsgBox "First limit length: " & CStr(dblFirstLimit)
    
End If

End Sub

Regards
Fernando

- Romania
- EU
 
Thanks Ferdo,

I've made a change to this, to obtain the plane name, and it worked like a rocket

Code:
Sub CATMain()

Dim varSelection As Variant
Set varSelection = CATIA.ActiveDocument.Selection
    
Dim InputFilter(0) As Variant
InputFilter(0) = "Pad"
    
Dim SelStatus As String
SelStatus = varSelection.SelectElement2(InputFilter, "Select Pad object", True)
    
Dim objPad As Pad
Dim objFirstLimit As Limit
Dim dblFirstLimit As String
    
If (SelStatus = "Normal") Then
        
    Set objPad = varSelection.Item2(1).Value
    Set objFirstLimit = objPad.FirstLimit
   
    dblFirstLimit = objFirstLimit.LimitingElement.DisplayName
    MsgBox "First limiting element is: " & dblFirstLimit
    
End If

End Sub

Tiago Figueiredo
Tooling Engineer
 
And if i want to know which plane, is a reference of an offset plane?

Tiago Figueiredo
Tooling Engineer
 
I would encourage you to record a macro of changing the reference of an existing feature in a CATPart. That should get you a long way towards your end goal. Reference elements(points/lines/planes) along with wire frame and surface features are recorded better than most other features. Generally you will get 80-90% of the code you require just by recording these activities. The Help Docs and/or V5Automation.chm in the CATIA installation path will also help to determine which properties and methods to use when attempting to access certain data within a CATIA model.

--Doug
 
you are right, but I've already that planes drawn in my part. But I want to know which plane is the reference of my offset plane. I only have found how to create it, not how to see which is its reference.


Tiago Figueiredo
Tooling Engineer
 
you said:
And if i want to know which plane, is a reference of an offset plane?

can you explain what you looking for?

Eric N.
indocti discant et ament meminisse periti
 
When i select plane.2, I whant that macro tells me that the reference plane is plane.1
Capture_xix0hv.png


Tiago Figueiredo
Tooling Engineer
 
My mistake, I completely misunderstood what you were asking.

What about using the DisplayName property of the Reference object you are retrieving from the Pad feature? You could then use the Selection object's Search function to retrieve the object by it's name and object type. This method wouldn't be bullet proof but should handle most situations well. Once you retrieve the HybridShapePlaneOffset object from the previous step, you can get it's planar reference with the Plane property and use the DisplayName property as you did with the Pad's limit.

--Doug
 
Can you show how? I haven't found how to do it?

"Once you retrieve the HybridShapePlaneOffset object from the previous step, you can get it's planar reference with the Plane property and use the DisplayName property as you did with the Pad's limit."

With pad it was simple to found the reference plane. But with the offset plane, i haven't found it.

Tiago Figueiredo
Tooling Engineer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top