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!

hybridshapeintersection

Status
Not open for further replies.

Sarry156

Aerospace
Aug 17, 2013
2
IN
Hai,
I have a Geometrical Set Containing Lines and a Surface in other Geometrical Set. All the Lines in the Geometrical Set doen't Intersect with the surface which i select. I want the intersection result of all the lines which intersect with the surface excluding the Lines which doen't intersect. How to do this using Catvba......Please Help.I am in urgent need....
 
Replies continue below

Recommended for you

Hi,

Try this,,
I've not tried this but sure that this works..
If its not working then try to modify it to suit to your need, functions works though

Code:
Dim oPart
Dim oGeometricalSetWithCreatedIntersection As HybridBody
Dim oSurface As HybridShape
Dim oLine As HybridShape
Dim oGeoSetWithLines As HybridBody

Set oPart = CATIA.ActiveDocument.Part
' Get All the Lines 
Set oGeometricalSetWithCreatedIntersection = .............. ' Add the geoset to which you want your intersection to get appended
Set oGeoSetWithLines = ............ '- Add your code here
Set oSurface = ................... '- Add the surface to this variable

If Not oGeoSetWithLines.Count = 0 Then
	For Each oLine In oGeoSetWithLines
		CreateIntersection oSurface, oLine, oGeometricalSetWithCreatedIntersection
	Next
End If 
'--- Code

Sub CreateIntersection (obj1 As Object, obj2 As Object, oGeoSetToAppend As HybridBody)
	If Not (obj Is Nothing) And (obj2 Is Nothing) Then
		Dim bIntersectsWithEachOther As Boolean
		bIntersectsWithEachOther = CheckIntersection (obj1, obj2)
		If bIntersectsWithEachOther Then
			call AddIntersection (obj1, obj2, oGeoSetToAppend)
		End If
	Else
		MsgBox "One of the Item sent for creating intersection is missing",VbOKOnly,"Create Intersection Failed"
	End If
End Sub
Sub AddIntersection (obj1 As Object, obj2 As Object, oAppendTo As HybridBody )
	Dim ref1 As Reference
	Set ref1 = oPart.CreateReferenceFromObject(input1)
	Dim ref2 As Reference
	Set ref2 = oPart.CreateReferenceFromObject(input2)
	Dim new_int As HybridShapeIntersection
	Set new_int = CurHSFactory.AddNewIntersection(ref1, ref2)
	oAppendTo.AppendHybridShape new_int
	oPart.UpdateObject new_int
End Sub
' CheckIntersection
Function CheckIntersection(Object1 As Variant, Object2 As Variant) As Boolean
	On Error GoTo Blast
	Dim TestInt As HybridShapeIntersection
	Dim oSel As Variant
	Set oSel = CATIA.ActiveDocument.Selection
	Set TestInt = MyHSFactory.AddNewIntersection(Object1, Object2)
	CATIA.ActiveDocument.Part.UpdateObject TestInt
	CheckIntersection = True
	' Delete the intersection otherwise it will get embedded into the document 
	' though user cant see this in tree until it gets appended to a Geometrical Set.
	' later This can only be deleted from using CATDUA tool.
	oSel.Clear
	oSel.Add TestInt
	oSel.Delete
	oSel.Clear
	Exit Function
Blast:
	CheckIntersection = False
End Function

Hope this might help you.

Regards,
Maddy

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top