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!

Offset Surface - Macro

Status
Not open for further replies.

DomKum

Automotive
Nov 27, 2005
23
IN
Hi Experts,

Below is the Macro which will offset the all the surfaces in the selected GS.
I have two issues in which I need guidance/help
1. All the surfaces to be offset based on the user request Like - In / Out. Currently its happening on the side based on iorientation = True/False.
2. Ignore the element which is failing by deactivating and go to next
---> Here even though I have included "On Error Resume Next" - upon fist encounter of error element - MACRO is not able to update the successful element

Language="VBSCRIPT"

Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument

Set part1 = partDocument1.Part

Set hybridBodies1 = part1.HybridBodies

Offsetvalue = Inputbox("Enter the value offset")

Dim InputObjectType(0)

Set hybridBody1 = hybridBodies1.Add()
Set hybridBody1 = CATIA.ActiveDocument.Part.InWorkObject

msgbox ("Select the geometrical set")

Set oSelection = CATIA.ActiveDocument.Selection
oSelection.Clear
InputObjectType(0) = "HybridBody"
Status = oSelection.SelectElement2(InputObjectType, "Select Geometrical set.", True)

Set hybridBody1 = hybridBodies1.Add()
Set hybridBody1 = CATIA.ActiveDocument.Part.InWorkObject

Dim iCount
Dim i 'As Integer


oSelection.Search "CATGmoSearch.Surface,sel"
iCount = oSelection.Count
For i =1 to iCount

'-----------With the statement as below each item name in the selected GS will be displayed
Set USel = CATIA.ActiveDocument.Selection
'MsgBox(USel.Item(i).Value.Name)
'--------------- 09-Macro_to_display_selected_items.catvbs - reference macro for this statement

On Error Resume Next

Set hybridShapeFactory1 = part1.HybridShapeFactory

Set hybridShapeSurfaceExplicit1 = oSelection.Item(i).Value

Dim reference1 'As Reference

Set reference1 = part1.CreateReferenceFromObject(hybridShapeSurfaceExplicit1)

Set hybridShapeOffset1 = hybridShapeFactory1.AddNewOffset(reference1, Offsetvalue, True, 0.010000)

Set hybridBodies1 = part1.HybridBodies

hybridBody1.AppendHybridShape hybridShapeOffset1

part1.InWorkObject = hybridShapeOffset1

If Err.Number <> 0 Then

Selection.Clear
Selection.Delete
End If

part1.Update
Err.Clear
Next
part1.Update

msgbox ("Total number of surfaces offseted are " &iCount)

End Sub



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top