Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Select group by them name in a journal

Status
Not open for further replies.

bastiensegond

Aerospace
Jul 5, 2011
21
FR
Hi,

Is it possible in a journal to select some groups by them names?

I want to select groups whom the name begin by "post_" in a .sim file.

Thanks

Bastien
NX7.5.4.4
 
Replies continue below

Recommended for you

Bastien,

I work for Siemens PLM and know a couple guys familiar with NX Open. I'm ghost writing for them. Without knowing the intent of the group query, here are a couple suggestions from them (i.e. not me):

loop through the groups to find the desired name, i.e.:

' Get the base part
Dim basePart As BasePart = theSession.Parts.BaseWork

' Test to ensure it is a SIM part
If (basePart Is Nothing Or Not TypeOf basePart Is CAE.SimPart) Then
theNXMessageBox.Show(MessageBoxTitle, NXMessageBox.DialogType.Error, "SIM Part must be loaded")
Return
End If

Dim simPart As CAE.SimPart = CType(basePart, CAE.SimPart)

For Each caeGroup As CAE.CaeGroup In simPart.CaeGroups.ToArray
If Left(caeGroup.Name, 5) = "post_" Then
' Insert your code here
End If

'Alternative
If InStr(caeGroup.Name, "post_") = 1 Then
' Insert your code here
End If
Next caeGroup

A similar approach is shown next. The point of emphasis is identifying the groups by looping through them similar to what is above:

Dim groups As CAE.CaeGroup() = part.CaeGroups().ToArray()

For Each group As CAE.CaeGroup In groups

If group.Name.StartsWith("post_") Then

End If
Next ' For Each group

The VB program below (and attached as a file) will cycle through all groups in a SIM file and output data to the information window. This was written with NX 7.5.4. I successfully tested it with NX 7.5.4 but didn’t try other versions. The check for the group name is case sensitive. I tried groups named "Post_*" and "post_*". It listed out the "post_*" groups only.

' NX 7.5.4.0
' Journal created by golfisd on Tue Apr 12 13:26:24 2011 Eastern Daylight Time
'
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal88
Dim theSession As Session = Session.GetSession()
Dim theResultManager As CAE.ResultManager = theSession.ResultManager
Dim theLW As ListingWindow = theSession.ListingWindow

Sub Main()
Dim detailLevel As Integer = 0
Dim basePart As BasePart = theSession.Parts.BaseWork

Dim caePart As CAE.CaePart = Nothing

If TypeOf basePart Is CAE.CaePart Then
caePart = CType(basePart, CAE.CaePart)
End If

processCaePart(caePart, detailLevel)

End Sub
Sub processCaePart(ByVal part As CAE.CaePart, ByVal detailLevel As Integer)


If part Is Nothing Then
WriteLine(" CaePart:: nothing input ")
Return
End If



Dim groups As CAE.CaeGroup() = part.CaeGroups().ToArray()

WriteLine("CaePart named [" + part.FullPath + "] has nCaeGroups = [" + groups.Length.ToString + "] tag = " + part.Tag.ToString)

For Each group As CAE.CaeGroup In groups

If group.Name.StartsWith("post_") Then

Dim taggedObjs As TaggedObject() = group.GetEntities()

WriteLine(" CaeGroup named [" + group.Name + "] nMembers = " + taggedObjs.Length.ToString + " tag = " + group.Tag.ToString + " type = " + group.GetType.ToString)


If detailLevel > 0 Then

For Each taggedObj As TaggedObject In taggedObjs
WriteLine(" Member Tag =" + taggedObj.Tag.ToString + " Obj Type = " + taggedObj.GetType.ToString)

Next 'For Each taggedObj

End If ' if detailLevel > 0
End If
Next ' For Each group

End Sub
Sub WriteLine(ByRef line As String)
Dim theLW As ListingWindow = theSession.ListingWindow

If (theLW.IsOpen = False) Then theLW.Open()

theLW.WriteLine(line)

End Sub
End Module

Regards,
Mark

Mark Lamping
CAE Technical Consultant
Siemens PLM Software
(513) 576-2073
mark.lamping@siemens.com
 
Mark,

thanks you, it's work.

I work on journals in .sim files. I'm a beginner.

Have you some samples of journals to execute in .sim files?

Thanks.
Bastien.
 
Bastien,

There are a few CAE oriented NX Open examples here:


Go to the Communities SIGs and Focus Groups


Then sign up for the NX Simulation SIG (Special Interest Group). That group contains a File Library called NX Open Routines. So far there are 5 routines located there, but internally we've developed many more for users.

Note that you have to be a member of PLM World first before you can request access to the SIGs. Let me know here if you need further assistance.

Regards,
Mark

CAE Technical Consultant
Siemens PLM Software
 
Mark,

I have others questions.

Is it possible to include a WindowsForm or equivalent in a journal ? I have find UI block styler but we have not the licence.

I want to create a graphical user interface. Is it possible?

Thank you very much.

Bastien.
 
Bastien,

I'm told that it is possible. You need to add:

Imports System.Windows.Forms

to the journal. The attached example copies an assembly to a selected directory via standard Windows UI. It runs fine for me using NX 7.5.4.

Should you convince your management to purchase a license of the block styler product, make sure it includes the Block UI Styler application as opposed to the User Interface Styler application. The Block UI Styler application builds dialogs that are consistent with the NX UI from NX 6 onwards. I can't comment on the proper products/licenses, but I do know the preferred application is Block UI Styler.

Regards,
Mark

Mark Lamping
CAE Technical Consultant
Siemens PLM Software
 
 http://files.engineering.com/getfile.aspx?folder=b4d17a3f-f0ef-4bd3-a0bf-fff21b59fe5a&file=copy_to_dir.vb
Mark,

The program you sent me is working properly. I'm leaving tonight on vacation for two weeks.

Can you give me your email address to contact you when I return?

Thank you.

Bastien.
 
Mark,

I'm back from vacation. I have another question about the journals. Is it possible with a function to retrieve the name of the .sim file and the solution in which we work?

Regards,
Bastien.
 
Bastien,

Unfortunately I'm ghost writing here with respect to NX Open questions. My programming skills are dismal at best. Perhaps the NX online help has the answer to this buried in the NX Open for .NET Reference Guide. To get to that launch the online help. Then expand the Automation topic. Go to NX Open and then Open for .NET. There you will find the .NET reference guide.

Another option would be to open a call with GTAC. I'll ping my sources too and post an answer here assuming I get one.

Regards,
Mark

Mark Lamping
CAE Technical Consultant
Siemens PLM Software
 
Mark,

I find too in the online help and in the .NET Reference Guide.
Thank you for your answers.

Bastien.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top