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

@hkempeneers,

 

Try below iLogic code.

Dim comp As ComponentOccurrence   
comp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Selecteer een component")  

If TypeOf oOccurrence Is ComponentOccurrenceProxy Then

    Prop = iProperties.Value(comp.NativeObject.Name, "Project", "Description")

Else 

    Prop = iProperties.Value(comp.Name, "Project", "Description")

End If 

Dim oAssDef As AssemblyComponentDefinition = ThisDoc.Document.ComponentDefinition

Dim oFace As Face

oFace = ThisApplication.CommandManager.Pick (SelectionFilterEnum.kAllPlanarEntities,"Selecteer een vlak") 

'		make sure it Is a planar face

If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then

		Dim oFaceProxy As FaceProxy 
		comp.CreateGeometryProxy(oFace, oFaceProxy)

		oPlanarSurface = oFace.Geometry 
		'add a sketch

		oSketch = oAssDef.Sketches.Add(oFaceProxy)  

		'trying to choose an appropriate point

		'assume this planar face has one edge loop only

		oEdgeLoop = oFaceProxy.EdgeLoops(1) 

		oMinPt = oEdgeLoop.RangeBox.MinPoint 

		oMaxPt = oEdgeLoop.RangeBox.MaxPoint 

		CenterPt = ThisApplication.TransientGeometry.CreatePoint((oMaxPt.X + oMinPt.X) / 2#, (oMaxPt.Y + oMinPt.Y) / 2#, (oMaxPt.Z + oMinPt.Z) / 2#)    

		'get one point on the face and transform to the point2d on the sketch 

		'oTextPt = oSketch.ModelToSketchSpace(oPlanarSurface.RootPoint)

		oTextPt = oSketch.ModelToSketchSpace(CenterPt) 

		'add the textbox

		oSketchText = oSketch.TextBoxes.AddFitted(oTextPt, "<StyleOverride FontSize='30'>" & Prop & "</StyleOverride>")

Else

		MsgBox( "Selecteer een vlak, en geen ronding, aub!")

End If

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network