AnsweredAssumed Answered

Linking sketch text to custom property

Question asked by Mark Schwandt on Jul 1, 2016
Latest reply on Jul 14, 2016 by Mark Schwandt

I've written a macro that creates a little placeholder item for parts that go on our BOMs but aren't real items. I can get it to make the part, add the text, and change the sketch text font parameters. The one thing I can't seem to get to work is setting the text to a file property link within the macro. It always wants to fill in the value of the custom property to the sketch text, not create the link. I've tried setting the name of the link to a string, (LName = "$PRP:" & CHR(34) & "Drawing No."&CHR(34)) . Then I add the the sketch to a face to extrude it:

 

(face already selected in macro)

 

' Add the Drawing No. text to the face

 

boolstatus = swExt.SelectByID2("", "FACE", -5.2647223348572E-03, -7.04248185229517E-04, 2.53999999756616E-04, False, 0, Nothing, 0)

Set vSkLines = swSketchMgr.CreateCenterLine(-0.01905, -0.003081, 0#, 0.01905, -0.003081, 0#)

boolstatus = swExt.SelectByID2("Point1@Origin", "EXTSKETCHPOINT", 0, 0, 0, False, 0, Nothing, 0)

boolstatus = swExt.SelectByID2("Line1", "SKETCHSEGMENT", 1.82047161818376E-04, -2.96876910042268E-03, 1.27000000000021E-04, True, 0, Nothing, 0)

Set Annotation = swModel.AddDimension2(2.07113655637978E-02, -1.5123918058757E-03, 0.000254)

swModel.ClearSelection2 True

Set myDimension = swModel.Parameter("D1@Sketch2")

myDimension.SystemValue = 0.003175

 

boolstatus = swExt.SelectByID2("Line1", "SKETCHSEGMENT", -8.54221297763129E-04, -3.08079812308014E-03, 1.27000000000022E-04, False, 1, Nothing, 0)

Set vSkLines = swModel.InsertSketchText(0, 0, 0, LName, 1, 0, 0, 80, 100)

swModel.ClearSelection2 True

 

' Here I change the default font and text height

 

boolstatus = swExt.SelectByID2("SketchText1", "SKETCHTEXT", 0, 0, 0, False, 0, Nothing, 0)

Set SelMgr = swModel.SelectionManager

Set swSketchText = SelMgr.GetSelectedObject6(1, 0)

Set swTextFmt = swSketchText.GetTextFormat

 

swTextFmt.CharHeight = 0.00635

swTextFmt.TypeFaceName = "Arial"

 

'swModel.InsertSketch2 True

boolstatus = swSketchText.SetTextFormat(False, swTextFmt)

 

' Extrude the Text

 

Set swFeature = swModel.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, 0.000254, 0.000254, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, True, True, True, 0, 0, False)

 

But no matter what I try, It defaults by putting in the value of the custom property "Drawing No." and not the link.

 

Any suggestions?

Attachments

Outcomes