Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Hi I want to use this journal to

Status
Not open for further replies.

Ehaviv

Computer
Jul 2, 2003
1,012
Hi

I want to use this journal to list part attributes that have 'reference text'
linked to theme. can someone help ? which nxopen function to use ?

I mean a 'reference text' that builded this way:
In drafting I open the Note Dialog and click the Insert Part Attribute icon and I select an attribute
and that create This <WRef1*0@Title1> on the dialog and the 'reference text' on the graphics window.

Option Strict Off

Imports System

Imports NXOpen
Imports NXOpen.UF

Module show_part_user_attributes

Sub Main()

Dim s As Session = Session.GetSession()
Dim lw As ListingWindow = s.ListingWindow()
Dim ufs As UFSession = UFSession.GetUFSession()

Dim markId1 As Session.UndoMarkId
markId1 = s.SetUndoMark(Session.MarkVisibility.Visible, "Report Body Attributes")

lw.Open()
ufs.Ui.ExitListingWindow() ' Clear and close the window

Dim ndx As Integer
Dim attrInfo() As NXObject.AttributeInformation

Try

attrInfo = s.Parts.Work.GetUserAttributes()

For ndx = 0 To attrInfo.Length - 1
lw.WriteLine("Title = " & attrInfo(ndx).Title & " Value = " _
& attrInfo(ndx).StringValue & vbCrLf)
Next

Catch ex As Exception
MsgBox(ex.ToString(), MsgBoxStyle.Critical)
End Try

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY
End Function

End Module

Thanks in advanced
 
Replies continue below

Recommended for you

I don't know of any NXOpen function that will report the annotation objects that use a particular attribute. Alternatively, you can search through the annotation objects looking for those that reference your attribute.

www.nxjournaling.com
 
Hi Cowski

Meanwhile till your post I found a class that deal with this
AssociativeText and with Google search I found a little
Help to make me start

Thank you for this post
 
Hi Cowski

This line was the key for me to know how to use the methods of AssociativeText class

at = wp.Annotations.CreateAssociativeText()

I found this help in the line

Annotations::AssociativeText *theAT = workPart->Annotations()->CreateAssociativeText();

in this site


And after playing with the method

found = at.GetPartAttribute(t1, attTitle)

I found that if an AssociativeText is a standalone found = true so in this case all is OK

but if a line is like this

"start with regular text <WRef6*0@DB_PART_REV> end with regular text"

found = false

and finaly a surprise if a line contains a regular text but start with an AssociativeText like this

"<WRef6*0@DB_PART_REV> additional regular text"

the found return true.

so the solution is the folowing linse.

For s1 = 0 to textLine(tL).Length - 1
t1 = textLine(tL).SubString(s1)
found = at.GetPartAttribute(t1, attTitle)

The journal can be used to edit drafting decall that based on AssociativeText

************* the code start here need NX853 *******************

Option Strict Off

Imports System
Imports System.IO

Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI.NXInputBox
Imports System.Collections

Module edit_associativetext_for_note_or_label

Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim ui As UI = ui.GetUI()
Dim lw As ListingWindow = s.ListingWindow

Sub Main(ByVal args As String())

Dim wp As Part = s.Parts.Work
Dim new_string As String
Dim old_string As String
Dim obj As NXObject
Dim cursor As Point3d = Nothing
Dim textLine As String()
Dim attTitle As String
Dim tL As Integer
Dim resp As Integer
Dim s1 As Integer
Dim t1 As String
Dim aNote As Annotations.NoteBase
Dim found As Boolean
Dim atLeastOne As Boolean
Dim alreadyProcessed As Hashtable
Dim at As Annotations.AssociativeText

at = wp.Annotations.CreateAssociativeText()

alreadyProcessed = New Hashtable
lw.Open()

While SelectNoteorLabel(obj, cursor) = Selection.Response.Ok

aNote = obj

textLine = aNote.GetText()
alreadyProcessed.Clear()

For tL = 0 To textLine.Length - 1

atLeastOne = False

If textLine(tL) = "" Then Continue For

Try

For s1 = 0 to textLine(tL).Length - 1

t1 = textLine(tL).SubString(s1)
found = at.GetPartAttribute(t1, attTitle)

If found = True Then
atLeastOne = True

If Not alreadyProcessed.Contains(attTitle) Then
alreadyProcessed.Add(attTitle, attTitle)

old_string = wp.GetStringUserAttribute(attTitle, -1)
new_string = GetInputString(attTitle & " : Attribute Value", _
at.GetPartAttributeText(attTitle), old_string)

If new_string = "" Then
resp = ui.NXMessageBox.Show(textLine(tL), NXMessageBox.DialogType.Question, _
"Delete " & attTitle & " : Attribute Value ?")
If resp = 1 Then
new_string = ""
Else
new_string = old_string
End If
End If
wp.SetUserAttribute(attTitle, -1, new_string, Update.Option.Now)
End If
End If
Next

Catch ex As Exception
msgbox(ex.ToString())
Continue For ' ?
End Try

If atLeastOne = False Then msgbox(textLine(tL) & vbCrLf & vbCrLf & _
"This is not an AssociativeText object")

Next

End While

End Sub

Public Function SelectNoteorLabel(ByRef obj As NXObject, _
ByRef cursor As Point3d) As Selection.Response
Dim mask(1) As Selection.MaskTriple
mask(0).Type = NXOpen.UF.UFConstants.UF_drafting_entity_type
mask(0).Subtype = NXOpen.UF.UFConstants.UF_draft_note_subtype
mask(1).Type = NXOpen.UF.UFConstants.UF_drafting_entity_type
mask(1).Subtype = NXOpen.UF.UFConstants.UF_draft_label_subtype
Dim resp As Selection.Response = ui.SelectionManager.SelectObject( _
"Edit AssociativeText for example <WRef6*0@DB_PART_REV>", _
"Select Note or Label to edit", Selection.SelectionScope.WorkPart, _
Selection.SelectionAction.ClearAndEnableSpecific, False, _
False, mask, obj, cursor)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function

End Module
 
sory for the bad link
I copy paste its contains

Point* getCompPoint(Assemblies::Component* comp, string name){
Point* pnt = NULL;
Part* prt = NULL;
tag_t occ = 0;
Features::FeatureCollection* fc;
prt = dynamic_cast<Part*>(comp->Prototype());
if (!prt) //Prototype der Komponente nicht gefunden
return NULL;

//Features des Parts durchsuchen
fc = prt->Features();
for (Features::FeatureCollection::iterator it = fc->begin(); it != fc->end(); ++it){
if (!strcmp(name.c_str(),(*it)->Name().GetLocaleText()) &&
!strcmp("POINT",(*it)->FeatureType().GetLocaleText()))
{
pnt = dynamic_cast<Point*>((*it)->GetEntities().at(0)); //Punkt des Features im Part
break;
}
}
if (!pnt) //Punkt im Part nicht gefunden
return NULL;

occ = UF_ASSEM_find_occurrence(comp->Tag(),pnt->Tag());
pnt = NULL;
if (!occ) //Punkt in Komponente nicht gefunden
return NULL;

//Punktobjekt vom Tag generieren
NXObjectManager* objM = new NXObjectManager();
pnt = dynamic_cast<Point*>(objM->Get(occ));
delete objM;

return pnt;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor