Awsome!
Changed it somehow to take a custom property and let the user select the face.
Is it possible to change the font size? since the part is a few meters in size, I have to use fontsize 300.
Also if its possible, add the text as a text-box, that way no text-point is visible.
SyntaxEditor Code Snippet
oAssDoc = ThisApplication.ActiveDocument
oAssDef = oAssDoc.ComponentDefinition
itemNo = iProperties.Value("Custom", "ItemNo")
Dim oFace As Face
oFace = ThisApplication.CommandManager.Pick (SelectionFilterEnum.kAllPlanarEntities,"Select the face")
'make sure it is a planar face
If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then
oPlanarSurface = oFace.Geometry
'add a sketch
oSketch = oAssDef.Sketches.Add(oFace)
'trying to choose an appropriate point
'assume this planar face has one edge loop only
oEdgeLoop = oFace.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
'Set oTextPt = oSketch.ModelToSketchSpace(oPlanarSurface.RootPoint)
oTextPt = oSketch.ModelToSketchSpace(CenterPt)
'add the textbox
'oSketchText = oSketch.TextBoxes.AddFitted(oTextPt, "MY TEST")
oSketchText = oSketch.TextBoxes.AddFitted(oTextPt, itemNo)
Else
MsgBox( "please select a planar face!")
End If