Using iLogic to make bisecting centerlines

Using iLogic to make bisecting centerlines

grantDHM4Z
Participant Participant
312 Views
3 Replies
Message 1 of 4

Using iLogic to make bisecting centerlines

grantDHM4Z
Participant
Participant

I'm trying to do something that seems simple, but it's giving me a tough time. I want an ilogic program to bisect two lines of a swept hole to create a centerline in the section view of a drawing. Automated centerlines won't work in this case for some reason, probably because its a sweep rather than a hole. I don't want to have to select the edges with mouse clicks. The edges will be the same on every drawing made from this part. It will be part of a rule that creates the drawing view. I have tried using named entities in the model to create edges and then geometry intent but no luck so far. Attached is a video of what I'm trying to do. Seems so simple on the video but it's not working yet. I tried asking chatgpt and was running in circles with it. Any ideas?

 

'Piezometer hole Centerline
Dim
oPhole As Edge = oNEsFO.FindEntity("P-hole") If oPhole Is Nothing Then MessageBox.Show("Edge 'P-hole' not found.") Return End If 'This code runs successfully and the edge is found edgeCurvesPhole = oSectionViewFOHPT.DrawingCurves(oPhole) 'I dont think anything past here works Dim pholetopline As GeometryIntent = oSheet2.CreateGeometryIntent(edgeCurvesPhole(1)) Dim pholebtmline As GeometryIntent = oSheet2.CreateGeometryIntent(edgeCurvesPhole(2)) Dim CLPholeFO As Centerline = oSheet2.Centerlines.AddBisector(pholetopline,pholebtmline)

 

0 Likes
313 Views
3 Replies
Replies (3)
Message 2 of 4

a.brusamolino
Enthusiast
Enthusiast

Hi!
Try seeing if this method could work for you.
Basically, in the 3D model, assign a name to the face you created, using Assign Name to Entity (e.g. "Faccia0")

 

AssegnaNome.pngAssegnaNome1.png

 

 

And then, in the drawing, once you've identified the view you're interested in, you can do something like this:

 

Dim count = 0
Dim oGI(1) As GeometryIntent

For Each oCurve In oView.DrawingCurves
	If TypeOf(oCurve.ModelGeometry) Is Face Then
		oFace = oCurve.ModelGeometry
		Try
			EntityAttributeSet = oFace.AttributeSets("iLogicEntityNameSet")
			EntityName = EntityAttributeSet.Item("iLogicEntityName").Value
		Catch
			Continue for
		End Try		
		If EntityName = "Faccia0" Then
			oGI(count) = oSheet.CreateGeometryIntent(oCurve)
			count += 1
		End If
	End If
Next
Dim CLPholeFO As Centerline = oSheet.Centerlines.AddBisector(oGI(0), oGI(1))

 

Hope it helps!

Message 3 of 4

Stakin
Collaborator
Collaborator

Something like below,try

Dim oFeatureName As string="P-hole"
Dim oDoc As PartDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument

Dim oFeature As PartFeature = oDoc.ComponentDefinition.Features(oFeatureName)
Dim oCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

For Each oCurve As DrawingCurve In oView.DrawingCurves	
	For Each oFace As Face In oFeature.Faces
		If oCurve.ModelGeometry Is oFace Then oCol.Add(oCurve)
	Next
Next

Dim oCenterLine As Centerline 

  Dim oCurve1 As DrawingCurve, oCurve2 As DrawingCurve
    oCurve1 = oCol(1)
    oCurve2 = oCol(2)
    Dim oIntent1 As GeometryIntent, oIntent2 As GeometryIntent
    oIntent1 = oSheet2.CreateGeometryIntent(oCurve2)
    oIntent2 = oSheet2.CreateGeometryIntent(oCurve1)  
	oCenterLine = oSheet2.Centerlines.AddBisector(oIntent1,oIntent2)
Message 4 of 4

grantDHM4Z
Participant
Participant

Sorry for the late response but thanks to both of you for your answers. I was able to get it with some finagling. Here's the final code I used for anyone interested.  

 

' Initialize variables
Dim count As Integer = 0
Dim oGI(1) As Inventor.GeometryIntent
Dim oFace As Inventor.Face
Dim EntityAttributeSet As Inventor.AttributeSet
Dim EntityName As String

' Loop through the drawing curves in the drawing view
For Each oCurve In oSectionViewFOHPT.DrawingCurves
    If TypeOf(oCurve.ModelGeometry) Is Inventor.Face Then
        oFace = oCurve.ModelGeometry

        ' Begin error suppression
        On Error Resume Next

        ' Attempt to get the entity name from the attribute set
        EntityAttributeSet = oFace.AttributeSets("iLogicEntityNameSet")
        EntityName = EntityAttributeSet.Item("iLogicEntityName").Value

        ' Check for error
        If Err.Number <> 0 Then
            Err.Clear()
            On Error GoTo 0
            Continue For
        End If

        ' Restore normal error behavior
        On Error GoTo 0

        ' Check if the entity name matches "Faccia0"
        If EntityName = "Faccia0" Then
            oGI(count) = oSheet.CreateGeometryIntent(oCurve)
            count += 1
        End If
    End If
Next

' Create centerline between the first two geometry intents (only if both were found)
If count = 2 Then
    Dim CLPholeFO As Inventor.Centerline = oSheet.Centerlines.AddBisector(oGI(0), oGI(1))
End If
   

 

0 Likes