Add textProfile to Sketch

Builder
Builder
            objRefplanes = ObjSheet.RefPlanes
            ObjRefPlane = objRefplanes.Item(1)
            ObjSketchs = ObjSheet.Sketches
            ObjSketch = ObjSketchs.Add()
            objProfiles = ObjSketch.Profiles
            objProfile = objProfiles.Add(ObjRefPlane)

I succeeded in creating my sketch on my flatpattern using this but now I'm stuck at the part where I have to insert a textprofile in the sketch. I found lots of examples showing how to draw lines and circles ( circles2d = objProfile.Circles2d

Circle2d = circles2d.AddByCenterRadius(0, 0, 0.05))

But Nothing on inserting TextProfiles at a precise point

I think it works with AnchorPointLocation.

 

ST9
Conveyor and industrial equipment designer.
Giving SE a chance.
3 REPLIES

Re: Add textProfile to Sketch

Builder
Builder

I believe this post http://community.plm.automation.siemens.com/t5/Solid-Edge-Developer-Forum/Change-string-value-of-tex... had a similar problem but it was more for editing the text, I actually want to create it, found the this Code in the SDK but it's for draft sheets, doea it work the same for textprofiles in sketches?

Imports System.Runtime.InteropServices
Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim objApp As SolidEdgeFramework.Application
        Dim objDoc As SolidEdgeDraft.DraftDocument
        Dim objSheets As SolidEdgeDraft.Sheets
        Dim objSheet As SolidEdgeDraft.Sheet
        Dim objTextProfiles As SolidEdgeFrameworkSupport.TextProfiles
        Dim objTextProfile As SolidEdgeFrameworkSupport.TextProfile
        Dim objLineSpacing As Double
        Dim count As Long
        Dim dblMargin As Double
        Dim dblLetterSpacing As Double
        Dim smoothness As Long
        Dim textsize As Double
        Dim textprofile As String
        Dim xfrom, yfrom, xto, yto As Double
        Dim font As String
        Dim justifvalue As SolidEdgeFrameworkSupport.TextNumberJustificationConstants
        Dim anchorptloc As SolidEdgeFrameworkSupport.AnchorPointLocationConstants
        Dim x As Double
        Dim y As Double


        Try
            xfrom = 0.5
            yfrom = 0.5
            xto = 0.7
            yto = 0.7
            objApp = Marshal.GetActiveObject("SolidEdge.Application")
            objDoc = objApp.ActiveDocument
            objSheets = objDoc.Sheets
            objSheet = objDoc.ActiveSheet
            objTextProfiles = objSheet.TextProfiles
            objTextProfile = objTextProfiles.Item(1)
            textprofile = objTextProfile.Text
            anchorptloc = objTextProfile.AnchorPointLocation
            Call objTextProfile.GetAnchorPoint(x, y)
            Call objTextProfile.SetAnchorPoint(0.4, 0.4)

            objTextProfile.AnchorPointLocation = SolidEdgeFrameworkSupport.AnchorPointLocationConstants.igAnchorPointMiddleRight
            anchorptloc = objTextProfile.AnchorPointLocation

            Call objTextProfile.GetAlignment(0, justifvalue)
            font = objTextProfile.FontName
            count = objSheet.TextProfiles.Count
            objLineSpacing = objTextProfile.LineSpacing
            dblMargin = objTextProfile.Margin
            dblLetterSpacing = objTextProfile.LetterSpacing
            smoothness = objTextProfile.Smoothness
            textsize = objTextProfile.TextSize
            Call objTextProfile.Move(xfrom, yfrom, xto, yto)
            objTextProfile.Copy()
            objTextProfile.Delete()
            'objTextProfile.Cut()

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

    End Sub

End Class
ST9
Conveyor and industrial equipment designer.
Giving SE a chance.

Re: Add textProfile to Sketch

Phenom
Phenom

Yes, I think so, it should.

The equivalent of a sheet in Part is the Profile declared as

Dim oActiveSketch As Profile

 

and accessed or assigned as

oActiveSketch = oDocP.ActiveSketch

 

Most 2D elements like lines and arcs are found here.

From there on, the line from your code:

objTextProfiles = objSheet.TextProfiles

 

should work like:

objTextProfiles = oActiveSketch.TextProfiles

 

This is just a guess though I haven't checked this in the API.

Re: Add textProfile to Sketch

Builder
Builder
    Sub Main()
        Dim objApp As SolidEdgeFramework.Application = Nothing
        Dim objDocs As SolidEdgeFramework.Documents = Nothing
        Dim ObjDocP As SolidEdgePart.SheetMetalDocument = Nothing
        Dim objPart As SolidEdgePart.PartDocument = Nothing
        Dim ObjSketchs As SolidEdgePart.Sketchs = Nothing
        Dim ObjSketch As SolidEdgePart.Sketch = Nothing

        Dim objProfileSets As SolidEdgePart.ProfileSets = Nothing
        Dim objProfileSet As SolidEdgePart.ProfileSet = Nothing
        Dim objProfiles As SolidEdgePart.Profiles = Nothing
        Dim objProfile As SolidEdgePart.Profile = Nothing
        Dim objRefplanes As SolidEdgePart.RefPlanes = Nothing
        Dim ObjRefPlane As SolidEdgePart.RefPlane = Nothing

        Dim ObjTextProfiles As SolidEdgeFrameworkSupport.TextProfiles = Nothing
        Dim ObjTextProfile As SolidEdgeFrameworkSupport.TextProfile = Nothing

        Dim objLineSpacing As Double
        Dim count As Long
        Dim dblMargin As Double
        Dim dblLetterSpacing As Double
        Dim smoothness As Long
        Dim textsize As Double
        Dim textprofile As String
        Dim xfrom, yfrom, xto, yto As Double
        Dim font As String
        Dim justifvalue As SolidEdgeFrameworkSupport.TextNumberJustificationConstants
        Dim anchorptloc As SolidEdgeFrameworkSupport.AnchorPointLocationConstants
        Dim x As Double
        Dim y As Double

        Try
            objApp = CType(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
            ObjDocP = objApp.ActiveDocument

            objRefplanes = ObjDocP.RefPlanes
            ObjRefPlane = objRefplanes.Item(1)
            ObjSketchs = ObjDocP.Sketches
            ObjSketch = ObjSketchs.Add()
            objProfiles = ObjSketch.Profiles
            objProfile = objProfiles.Add(ObjRefPlane)
        
            objProfile = ObjDocP.ActiveSketch

            ObjTextProfiles = objProfile.TextProfiles
            ObjTextProfile = ObjTextProfiles.Item(1)
            textprofile = ObjTextProfile.Text("mytexthere")
            anchorptloc = ObjTextProfile.AnchorPointLocation
            Call ObjTextProfile.GetAnchorPoint(x, y)
            Call ObjTextProfile.SetAnchorPoint(0.4, 0.4)

            ObjTextProfile.AnchorPointLocation = SolidEdgeFrameworkSupport.AnchorPointLocationConstants.igAnchorPointMiddleRight
            anchorptloc = ObjTextProfile.AnchorPointLocation

            Call ObjTextProfile.GetAlignment(0, justifvalue)
            font = ObjTextProfile.FontName("Solid Edge ISO")
            count = objProfile.TextProfiles.Count
            objLineSpacing = ObjTextProfile.LineSpacing
            dblMargin = ObjTextProfile.Margin
            dblLetterSpacing = ObjTextProfile.LetterSpacing
            smoothness = ObjTextProfile.Smoothness
            textsize = ObjTextProfile.TextSize
            Call ObjTextProfile.Move(xfrom, yfrom, xto, yto)
            ObjTextProfile.Copy()
            ObjTextProfile.Delete()
        Catch eX As Exception
        End Try

    End Sub

 Still just creates  a sketch....

ST9
Conveyor and industrial equipment designer.
Giving SE a chance.