Reply
Solved! Go to solution

Edit Text style for TextBox

Hi,

 

is there any API to modify the Text style for inserted textbox ? 

There is way to set the text style before inserting new textbox but there is no way to modify the style for the same textbox. 

 

Thanks in advance. Please let me know.

 

Sample code :

 

Type objType = null;

objType = Type.GetTypeFromProgID("SolidEdge.Application");

SolidEdgeFramework.Application objApplication = System.Runtime.InteropServices.Marshal.GetActiveObject("SolidEdge.Application") as SolidEdgeFramework.Application;

SolidEdgeFramework.SolidEdgeDocument seObjDocument = objApplication.ActiveDocument as SolidEdgeFramework.SolidEdgeDocument;

SolidEdgeDraft.DraftDocument draftDoc = seObjDocument as SolidEdgeDraft.DraftDocument;


SolidEdgeFramework.TextStyles textStyles = draftDoc.TextStyles;
List<string> tableS = new List<string>();
foreach (SolidEdgeFramework.TextStyle style in textStyles)
{
string nameOfStyle = style.Name;
tableS.Add(nameOfStyle);

}
textStyles.Active = "Onkar";

SolidEdgeDraft.Sheets draftSheets;
string activeSheetname = "Sheet1";
string textBoxname;
string layerName = "Default";
string text=" added this for testing \n I was here.\n Doing some testing.\n Got correct results.";
InsertTextBox(draftDoc, out draftSheets, text, activeSheetname, layerName, out textBoxname);


SolidEdgeFramework.SolidEdgeDocument seObjDocument2 = objApplication.ActiveDocument as SolidEdgeFramework.SolidEdgeDocument;

SolidEdgeDraft.DraftDocument draftDoc2 = seObjDocument2 as SolidEdgeDraft.DraftDocument;

SolidEdgeDraft.Sheets draftSheets2 = draftSheets = draftDoc2.Sheets;


SolidEdgeDraft.Sheet requiredSheet = null;

foreach (SolidEdgeDraft.Sheet item in draftSheets2)
{
if (item.Name == activeSheetname)
{
requiredSheet = item;
break;
}
}

SolidEdgeFrameworkSupport.TextBoxes textBoxesCollection = requiredSheet.TextBoxes as SolidEdgeFrameworkSupport.TextBoxes;
SolidEdgeFrameworkSupport.TextBox requiredTextBox = null;
foreach (SolidEdgeFrameworkSupport.TextBox textBox in textBoxesCollection)
{
if (textBox.Name == textBoxname)
{
requiredTextBox = textBox;
break;
}
}

SolidEdgeFramework.TextStyles textStyles2 = draftDoc.TextStyles;
List<string> tableS2 = new List<string>();
foreach (SolidEdgeFramework.TextStyle style2 in textStyles2)
{
string nameOfStyle1 = style2.Name;
tableS.Add(nameOfStyle1);

}

SolidEdgeFramework.SelectSet s=draftDoc.SelectSet;

s.Add(requiredTextBox);
textStyles2.Active = "Normal";

 

//Trying to set the style again for the same textbox which I have created on drawing file.

 

 

Thanks and Regards,

OnkarP

1 REPLY
Solution
Solution
Accepted by topic author SEWarrior12
‎02-14-2017 05:36 AM

Re: Edit Text style for TextBox

Hi,

 

Please Use "SolidEdgeFrameworkSupport.TextEdit".

 

i dont know in C#. i added in .net code,

 

objtexts = objsheet.textboxes

 

objtxt = objtxts.item(1)

 

dim objtxtedit as SolidEdgeFrameworkSupport.TextEdit

 

objtxtedit = objtxt.edit

 

objtxtedit.name = "new style name"

 

its worked for me, my "Normal" textstyle changed to my new textstyle "Test".

 

Also please use "Solidedge spy" for more details.