Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
If my model changes and the note becomes unattached, my textline "&REF_DES:AT_CONN" calling a parameter changes to "***".
Once I go through and reattach all the leaders, I can run this function to update all the notes back to "&REF_DES:AT_CONN", It only works if I've double clicked to edit the text before hand.
Has any one else had this issue? Does Toolkit also have this issue, or is this solely a weblink problem?
function Notevisit() {
if (pfcIsMozilla())
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var session = pfcGetProESession ();
var model = session.CurrentModel;
alert("STARTING NOTE REFRESH: PRESS 'OK', AND DO NOT TOUCH UNTIL 'DONE' IS DISPLAYED");
model.Regenerate(void null);
if (model == null)
return;
if (model.Type != pfcCreate("pfcModelType").MDL_DRAWING)
return;
var LABEL = "LABEL: &REF_DES:ATT_CONN";
var name = String(LABEL)
var LABEL = "LABEL: &REF_DES:ATT_CONN";
var name = String(LABEL)
var LABEL2 = "LABEL: \*\*\*";
var name2 = String(LABEL2)
var notes = model.ListItems(pfcCreate("pfcModelItemType").ITEM_DTL_NOTE);
for (var i = 0; i < notes.Count; i++) {
if (notes.Item(i).GetDetailType() === pfcCreate("pfcDetailType").DETAIL_NOTE) {
var item = notes.Item(i);
if (item.Type == pfcCreate("pfcModelItemType").ITEM_DTL_NOTE) {
if (item.GetDetailType() == pfcCreate("pfcDetailType").DETAIL_NOTE) {
var detailNoteInstructions = item.GetInstructions(true);
var content = "Got Error to modify note: "
var detailNoteInstructions = item.GetInstructions(true);
var textLines = detailNoteInstructions.TextLines;
for (j = 0; j < textLines.Count; j++) {
var texts = textLines.Item(j).Texts;
for (var k = 0; k < texts.Count; k++) {
content += texts.Item(k).Text;
texts.Item(k).Text = texts.Item(k).Text;
item.Modify(detailNoteInstructions);
if (texts.Item(k).Text == name2){
texts.Item(k).Text = name;
item.Modify(detailNoteInstructions);
}
}
}
}
}
}
}
model.Regenerate(void null);
}
Creo 9
Solved! Go to Solution.
I resolved the issue. The *** was being broken into a seperate text.item, so I updated my code to reflect that. Below is the functional code.
function Notevisit() {
if (pfcIsMozilla())
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var session = pfcGetProESession ();
var model = session.CurrentModel;
session.CurrentWindow.SetBrowserSize (0.0);
alert("STARTING NOTE REFRESH: PRESS 'OK', AND DO NOT TOUCH UNTIL 'DONE' IS DISPLAYED");
model.Regenerate(void null);
if (model == null)
return;
if (model.Type != pfcCreate("pfcModelType").MDL_DRAWING)
return;
var LABEL = "LABEL: &REF_DES:ATT_CONN";
var name = String(LABEL)
var LABEL3 = "\*\*\*";
var name3 = String(LABEL3)
var LABEL4 = "&REF_DES:ATT_CONN";
var name4 = String(LABEL4)
var LABEL5 = "LABEL: \*\*\*";
var name5 = String(LABEL5)
var notes = model.ListItems(pfcCreate("pfcModelItemType").ITEM_DTL_NOTE);
for (var i = 0; i < notes.Count; i++) {
if (notes.Item(i).GetDetailType() === pfcCreate("pfcDetailType").DETAIL_NOTE) {
var item = notes.Item(i);
item.Erase();
if (item.Type == pfcCreate("pfcModelItemType").ITEM_DTL_NOTE) {
if (item.GetDetailType() == pfcCreate("pfcDetailType").DETAIL_NOTE) {
var detailNoteInstructions = item.GetInstructions(true);
var textLines = detailNoteInstructions.TextLines;
for (j = 0; j < textLines.Count; j++) {
var texts = textLines.Item(j).Texts;
for (var k = 0; k < texts.Count; k++) {
if (texts.Item(k).Text == name3){
texts.Item(k).Text = name4;
item.Modify(detailNoteInstructions);
}
if (texts.Item(k).Text == name5){
texts.Item(k).Text = name;
item.Modify(detailNoteInstructions);
}
}
}
}
}
}
}
model.Regenerate(void null);
}
Erase (hide) the note before edit. Then show (display)
That didn't do it. I didn't realize before. It's actually crashing on these notes unless the textbox has been double clicked.
EDIT: Nevermind. It's not crashing on those. I just had a bug. It's still not working as intended. It's not changing them. I can see them being hidden/unhidden.
For reference, I attached a picture of the note, as well as the code with your suggestion implemented.
function maketable (point)
{
var session = pfcGetProESession ();
var drawing = session.CurrentModel;
var noteedge = pfcCreate ("pfcSelectionOptions").Create ("prt_or_asm");
noteedge.MaxNumSels = 1; // Only select one edge per loop iteration
var selections = void null;
try {
selections = session.Select (noteedge, void null);
}
catch (err) {
if (pfcGetExceptionType (err) == "pfcXToolkitUserAbort" ||
pfcGetExceptionType (err) == "pfcXToolkitPickAbove")
return (void null);
else
throw err;
}
if (selections.Count == 0)
return (void null);
var seledge = selections.selmodel;
//var fullname = seledge.getfullname()
//var pntSel = pfcCreate ("MpfcSelect").CreateComponentSelection (seledge, void null);
//var pOwnerA = seledge.getfullname;
//var p = drawing.SelectParameters();
var widths = new Array ();
widths [0] = 5.000;
widths [1] = 9.000;
widths [2] = 12.000;
widths [3] = 5.300;
widths [4] = 7.000;
//var entryarray = entries ();
var tabinstrs = pfcCreate ("pfcTableCreateInstructions").Create (point);
tabinstrs.SizeType = pfcCreate ("pfcTableSizeType").TABLESIZE_BY_NUM_CHARS;
var columnInfo = pfcCreate ("pfcColumnCreateOptions");
for (var j = 0; j < widths.length; j++)
{
var column = pfcCreate ("pfcColumnCreateOption").Create (
pfcCreate ("pfcColumnJustification").COL_JUSTIFY_CENTER, widths [j]);
columnInfo.Append (column);
}
tabinstrs.ColumnData = columnInfo;
var rowInfo = pfcCreate ("realseq");
for (var k = 0; k < 1; k++)
{
rowInfo.Append (2.3);
}
tabinstrs.RowHeights = rowInfo;
for (var k = 1; k < 5 + 2; k++)
{
rowInfo.Append (1.0);
}
tabinstrs.RowHeights = rowInfo;
var dwgTable = drawing.CreateTable (tabinstrs);
var topLeft = pfcCreate ("pfcTableCell").Create (1, 1);
var bottomRight = pfcCreate ("pfcTableCell").Create (1, 5);
dwgTable.MergeRegion (topLeft, bottomRight, null);
writeTextInCell (dwgTable, 1, 1, "REFDES" + "\n" + "("+")");
writeTextInCell (dwgTable, 2, 1, "PIN");
writeTextInCell (dwgTable, 2, 2, "TERMINAL");
writeTextInCell (dwgTable, 2, 3, "TERMINAL AWG");
writeTextInCell (dwgTable, 2, 4, "COLOR");
writeTextInCell (dwgTable, 2, 5, "WIRE #");
/*--------------------------------------------------------------------*\
For each entry port...
for(p=0; p<entryarray.Count; p++)
{
var entry = entryarray.Item (p);
writeTextInCell (dwgTable, p+3, 1, entry.Item());
writeTextInCell (dwgTable, p+3, 2, term.Item (0));
writeTextInCell (dwgTable, p+3, 3, termawg.Item (1));
writeTextInCell (dwgTable, p+3, 4, color.Item (2));
writeTextInCell (dwgTable, p+3, 4, wirenum.Item (2));
}
\*--------------------------------------------------------------------*/
dwgTable.Display ();
}
function Notevisit() {
if (pfcIsMozilla())
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var session = pfcGetProESession ();
var model = session.CurrentModel;
session.CurrentWindow.SetBrowserSize (0.0);
alert("STARTING NOTE REFRESH: PRESS 'OK', AND DO NOT TOUCH UNTIL 'DONE' IS DISPLAYED");
model.Regenerate(void null);
if (model == null)
return;
if (model.Type != pfcCreate("pfcModelType").MDL_DRAWING)
return;
var LABEL = "LABEL: &REF_DES:ATT_CONN";
var name = String(LABEL)
var LABEL2 = "LABEL: \*\*\*";
var name2 = String(LABEL2)
var notes = model.ListItems(pfcCreate("pfcModelItemType").ITEM_DTL_NOTE);
for (var i = 0; i < notes.Count; i++) {
if (notes.Item(i).GetDetailType() === pfcCreate("pfcDetailType").DETAIL_NOTE) {
var item = notes.Item(i);
item.Erase();
if (item.Type == pfcCreate("pfcModelItemType").ITEM_DTL_NOTE) {
if (item.GetDetailType() == pfcCreate("pfcDetailType").DETAIL_NOTE) {
var detailNoteInstructions = item.GetInstructions(true);
var textLines = detailNoteInstructions.TextLines;
//var attach = detailNoteInstructions.Leaders;
for (j = 0; j < textLines.Count; j++) {
var texts = textLines.Item(j).Texts;
for (var k = 0; k < texts.Count; k++) {
if (texts.Item(k).Text == name2 || texts.Item(k).Text == name){
texts.Item(k).Text = name;
item.Modify(detailNoteInstructions);
}
}
}
}
}
item.Show();
}
}
model.Regenerate(void null);
}
I resolved the issue. The *** was being broken into a seperate text.item, so I updated my code to reflect that. Below is the functional code.
function Notevisit() {
if (pfcIsMozilla())
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var session = pfcGetProESession ();
var model = session.CurrentModel;
session.CurrentWindow.SetBrowserSize (0.0);
alert("STARTING NOTE REFRESH: PRESS 'OK', AND DO NOT TOUCH UNTIL 'DONE' IS DISPLAYED");
model.Regenerate(void null);
if (model == null)
return;
if (model.Type != pfcCreate("pfcModelType").MDL_DRAWING)
return;
var LABEL = "LABEL: &REF_DES:ATT_CONN";
var name = String(LABEL)
var LABEL3 = "\*\*\*";
var name3 = String(LABEL3)
var LABEL4 = "&REF_DES:ATT_CONN";
var name4 = String(LABEL4)
var LABEL5 = "LABEL: \*\*\*";
var name5 = String(LABEL5)
var notes = model.ListItems(pfcCreate("pfcModelItemType").ITEM_DTL_NOTE);
for (var i = 0; i < notes.Count; i++) {
if (notes.Item(i).GetDetailType() === pfcCreate("pfcDetailType").DETAIL_NOTE) {
var item = notes.Item(i);
item.Erase();
if (item.Type == pfcCreate("pfcModelItemType").ITEM_DTL_NOTE) {
if (item.GetDetailType() == pfcCreate("pfcDetailType").DETAIL_NOTE) {
var detailNoteInstructions = item.GetInstructions(true);
var textLines = detailNoteInstructions.TextLines;
for (j = 0; j < textLines.Count; j++) {
var texts = textLines.Item(j).Texts;
for (var k = 0; k < texts.Count; k++) {
if (texts.Item(k).Text == name3){
texts.Item(k).Text = name4;
item.Modify(detailNoteInstructions);
}
if (texts.Item(k).Text == name5){
texts.Item(k).Text = name;
item.Modify(detailNoteInstructions);
}
}
}
}
}
}
}
model.Regenerate(void null);
}