Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Cadkunde.nl
in reply to: Cadkunde.nl

With the examples I built the following:

 

I'm able to make a solid feature that I can angle much like a flange, and be able to measure.

 

Public Sub Main()
	Dim partDoc As PartDocument = ThisDoc.Document
	Dim oCompDef As PartComponentDefinition = partDoc.ComponentDefinition
	
    Dim transBRep As TransientBRep = ThisApplication.TransientBRep
    Dim transGeom As TransientGeometry = ThisApplication.TransientGeometry

    Dim edge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select an edge.")
	Dim egdeLength As Double = ThisApplication.MeasureTools.GetMinimumDistance(edge.StartVertex, edge.StopVertex)
    Dim line As LineSegment = edge.Geometry

    Dim startPoint = line.StartPoint

    Dim translationVector = transGeom.CreateVector(startPoint.X, startPoint.Y, startPoint.Z)
    Dim vector1 = transGeom.CreateVector(0, 0, 1)
    Dim vector2 = line.Direction.AsVector()

    Dim matrix As Matrix = transGeom.CreateMatrix()
    matrix.SetToRotateTo(vector1, vector2)
    matrix.SetTranslation(translationVector)

    Dim boxMinPoint As Point = transGeom.CreatePoint(0, 0, 0)
	Dim boxMaxPoint As Point = transGeom.CreatePoint(0.3, -10, egdeLength)
    Dim box As Box = transGeom.CreateBox()
    box.Extend(boxMinPoint)
    box.Extend(boxMaxPoint)

    Dim oBody As SurfaceBody = transBRep.CreateSolidBlock(box)
	transBRep.Transform(oBody, matrix)
	
	matrix.SetToRotation(90*PI/180, vector2, line.StartPoint)
	transBRep.Transform(oBody, matrix)
	
	partDoc.ComponentDefinition.SetEndOfPartToTopOrBottom(True)
	Dim oBaseFeature As NonParametricBaseFeature = oCompDef.Features.NonParametricBaseFeatures.Add(oBody)
	partDoc.ComponentDefinition.SetEndOfPartToTopOrBottom(False)
End Sub

 

This is kinda what I wanted, but not sure if it is what I need.

Just need a 'face' in the position of the flange, before a flange is created, to measure it with workplane XY

I can measure the difference in angle in the direction of the flange.

If inventor measures an angle in the width direction of the flange, I can ignore it

If the angle of the flange is in +30deg/-30deg range of workplane XY, I should align the flange to be created with the workplane XY