Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple lines of text through journaling

Status
Not open for further replies.

multicaduser

Industrial
Jan 29, 2013
261
I would like to use a journal create multiple lines of text on a face from attributes. My issue is the code below was lifted from another program and I would like to loop through it passing the text and position without having to brute force repeat it for every line. It seems like it should be simple but so far it has not worked. Just looking for a nudge in the right direction.

tia

Code:
Dim nullNXOpen_Features_Text As NXOpen.Features.Text = Nothing
 
Dim textBuilder1 As NXOpen.Features.TextBuilder = Nothing
textBuilder1 = workPart.Features.CreateTextBuilder(nullNXOpen_Features_Text)
 
textBuilder1.TextString = Attline01
textBuilder1.FrameOnPath.AnchorPosition.Expression.RightHandSide = "50"
textBuilder1.Type = NXOpen.Features.TextBuilder.Types.OnFace
textBuilder1.PlanarFrame.Shear.RightHandSide = "5"
textBuilder1.FrameOnPath.AnchorLocation = NXOpen.GeometricUtilities.FrameOnPathBuilder.AnchorLocationType.Left
textBuilder1.FrameOnPath.AnchorPosition.Expression.RightHandSide = "3"
textBuilder1.FrameOnPath.Height.RightHandSide = "0.4"
textBuilder1.PrintMarkThickness.RightHandSide = "1"
textBuilder1.FrameOnPath.WScale = 150.0
textBuilder1.FrameOnPath.Offset.RightHandSide = "0"
textBuilder1.SelectFont("Modern", NXOpen.Features.TextBuilder.ScriptOptions.Oem)
 
Dim boundaryFaces1(-1) As NXOpen.Face
Dim faceTangentRule1 As NXOpen.FaceTangentRule = Nothing
faceTangentRule1 = workPart.ScRuleFactory.CreateRuleFaceTangent(pickFace, boundaryFaces1, 0.5)
 
Dim rules3(0) As NXOpen.SelectionIntentRule
rules3(0) = faceTangentRule1
textBuilder1.PlacementFaces.ReplaceRules(rules3, False)
 
textBuilder1.OnFacePlacementProfile.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves)
 
Dim features1(0) As NXOpen.Features.Feature
Dim aOCS1 As NXOpen.Features.AOCS = CType(feature1, NXOpen.Features.AOCS)
 
features1(0) = aOCS1
Dim line1 As NXOpen.Line = CType(aOCS1.FindObject("CURVE 1"), NXOpen.Line)
 
Dim nullNXOpen_Curve As NXOpen.Curve = Nothing
 
Dim curveFeatureTangentRule1 As NXOpen.CurveFeatureTangentRule = Nothing
curveFeatureTangentRule1 = workPart.ScRuleFactory.CreateRuleCurveFeatureTangent(features1, line1, nullNXOpen_Curve, False, 0.01, 0.5)
 
textBuilder1.OnFacePlacementProfile.AllowSelfIntersection(True)
 
Dim rules4(0) As NXOpen.SelectionIntentRule
rules4(0) = curveFeatureTangentRule1
Dim helpPoint2 As NXOpen.Point3d = New NXOpen.Point3d(-56.880335976917863, -6.0840221749458578e-14, 10.000000000000043)
textBuilder1.OnFacePlacementProfile.AddToSection(rules4, line1, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint2, NXOpen.Section.Mode.Create, False)
 
Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = textBuilder1.Commit()
 
textBuilder1.Destroy()

NX 1899 Windows 10
 
Replies continue below

Recommended for you

Hi
If there is a dialog box with 2 options 'text entry' and 'select face' is there , It may solve the issue.
 
RamK Thanks for the reply. The sample code has a brute force approach where everything is in the main program and the code in this post was repeated for each line. I'm in the process of taking this portion and putting it in a function that can be passed parameters for each line indicating position, text, text size, etc. Part of what I'm weeding through right now is figuring out what needs to be passed and what is actually needed to write the text.

There are other examples online but this one comes closest to what I'm trying to do. I'll post the code once I figure it out. Disclaimer, I'm a self taught programmer with lots of grey hair [bigsmile] so don't expect pretty code.

NX 1899 Windows 10
 
Crude as it is this will loop through and put text on a face. Other parts of the code have been omitted as it was looping through the text writing that was holding the program up. Admittedly I don't understand it completely but it does what is needed.

Code:
	Dim nullNXOpen_Features_Text As NXOpen.Features.Text = Nothing
	Dim faceTangentRule1 As NXOpen.FaceTangentRule = Nothing

	Dim aOCS1 As NXOpen.Features.AOCS = CType(feature1, NXOpen.Features.AOCS)

	Dim nullNXOpen_Curve As NXOpen.Curve = Nothing
	Dim curveFeatureTangentRule1 As NXOpen.CurveFeatureTangentRule = Nothing

	Dim helpPoint2 As NXOpen.Point3d = New NXOpen.Point3d(-56.880335976917863, -6.0840221749458578e-14, 10.000000000000043)
 	Dim nXObject1 As NXOpen.NXObject = Nothing

	Dim textBuilder3 As NXOpen.Features.TextBuilder = Nothing

	Dim boundaryFaces3(-1) As NXOpen.Face
	Dim faceTangentRule3 As NXOpen.FaceTangentRule = Nothing
	faceTangentRule1 = workPart.ScRuleFactory.CreateRuleFaceTangent(pickFace, boundaryFaces3, 0.5)

	Dim features3(0) As NXOpen.Features.Feature
	features3(0) = aOCS1

	Dim line4 As NXOpen.Line = CType(aOCS1.FindObject("CURVE 1"), NXOpen.Line)
	Dim curveFeatureTangentRule3 As NXOpen.CurveFeatureTangentRule = Nothing
	curveFeatureTangentRule3 = workPart.ScRuleFactory.CreateRuleCurveFeatureTangent(features3, line4, nullNXOpen_Curve, False, 0.01, 0.5)

	Dim rules8(0) As NXOpen.SelectionIntentRule
	rules8(0) = curveFeatureTangentRule3
	Dim helpPoint4 As NXOpen.Point3d = New NXOpen.Point3d(-56.880335976917863, -6.0840221749458578e-14, 10.000000000000043) 
	Dim nXObject3 As NXOpen.NXObject = Nothing


' ------------------
' write text to face
' ------------------

	Dim stepI As Integer = 1
	Dim AttrBase As String = ""
	Dim AttrFull As String = ""
	Dim AttrNumb As String = ""
	Dim txtPos As Double = 0
	Dim txtSiz As double = 0

	For stepI = 1 to 13
		if stepI = 1 then
			txtPos = 0
			txtSiz = .5
		else
			txtPos = -(.4*(stepI-1))
			txtSiz = .25
		end if

	textBuilder3 = workPart.Features.CreateTextBuilder(nullNXOpen_Features_Text) 
	textBuilder3.TextString = usrAttr(stepI,2) 
	textBuilder3.FrameOnPath.AnchorPosition.Expression.RightHandSide = "50"
	textBuilder3.Type = NXOpen.Features.TextBuilder.Types.OnFace
	textBuilder3.PlanarFrame.Shear.RightHandSide = "0"
	textBuilder3.FrameOnPath.AnchorLocation = NXOpen.GeometricUtilities.FrameOnPathBuilder.AnchorLocationType.Left
	textBuilder3.FrameOnPath.AnchorPosition.Expression.RightHandSide = "3"
	textBuilder3.FrameOnPath.Height.RightHandSide = Str(txtSiz)
	textBuilder3.PrintMarkThickness.RightHandSide = "1"
	textBuilder3.FrameOnPath.WScale = 150.0
	textBuilder3.FrameOnPath.Offset.RightHandSide = Str(txtpos)
	textBuilder3.SelectFont("Modern", NXOpen.Features.TextBuilder.ScriptOptions.Oem)
	faceTangentRule1 = workPart.ScRuleFactory.CreateRuleFaceTangent(pickFace, boundaryFaces3, 0.5)
	rules8(0) = faceTangentRule1
	textBuilder3.PlacementFaces.ReplaceRules(rules8, False)
	textBuilder3.OnFacePlacementProfile.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves)
	features3(0) = aOCS1
	curveFeatureTangentRule3 = workPart.ScRuleFactory.CreateRuleCurveFeatureTangent(features3, line4, nullNXOpen_Curve, False, 0.01, 0.5)
	textBuilder3.OnFacePlacementProfile.AllowSelfIntersection(True)
	rules8(0) = curveFeatureTangentRule3
	textBuilder3.OnFacePlacementProfile.AddToSection(rules8, line4, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint4, NXOpen.Section.Mode.Create, False)
	nXObject3 = textBuilder3.Commit()
	textBuilder3.Destroy()

	next

NX 1899 Windows 10
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor