×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Journal to find and move groups by names to a given layer??

Journal to find and move groups by names to a given layer??

Journal to find and move groups by names to a given layer??

(OP)
Is it possible, using a journal, to search for a group by name, ie group_a, group_b, group_c..., then move that group as well as its contents to a given layer?

I have tried recording a journal to do this, but it finds the group and objects all individually using a journal identifier, not by name.  From the recored journal placing the objects into an array then moving them should be fairly straight forward, workPart.Layers.MoveDisplayableObjects(destination_layer, objectArray1), but how whould one go about finding the group and its contents?

UG NX 6.0.4.3

RE: Journal to find and move groups by names to a given layer??

Hi,

You might have to access the UG/Open C wrapper functions to solve your issue.

First, you will need to collect (into an ArrayList, for example) all group objects with a specific name. Take a look at the NXOpen.UF.UFObj class to achieve this.

Once you have a collection, then it should only be a matter of moving these groups to a given layer.

HTH

RE: Journal to find and move groups by names to a given layer??

(OP)
I managed to find a method to accomplish this.  A sample code is below if anyone is interested.

CODE

Private Function move_group(Byref GROUP_NAME As String, Byref destination_layer As Integer)
    
    Dim theSession As Session = Session.GetSession()
    Dim WorkPart As Part = theSession.Parts.Work
    Dim TheUFsession As UFSession = UFSession.GetUFSession()
    Dim NULLTAG As Tag = NXOpen.Tag.Null
    Dim objectTag As Tag = NXOpen.Tag.Null
    Dim group_count As Integer = 0
    Dim group_list() As group
    Dim group_member_list() As tag
    dim member_count as integer

    theUfSession.Obj.CycleObjsInPart(workpart.Tag, NXOpen.UF.UFConstants.UF_group_type, objectTag)
    
    Do
        
        Dim mygroup As group = Nothing
        Dim myObject As NXObject = Nothing
        Dim group_object as nxobject
        Dim group_object_type as Integer
        dim group_object_subtype as Integer

        myObject = NXObjectManager.Get(objectTag)
        mygroup = CType(myObject, group)
        Array.Resize(group_list, group_count+1)
        group_list(group_count)=mygroup
        theufsession.group.AskGroupData(objecttag,group_member_list,member_count)
        msgbox("Found group " & mygroup.name & ", it contains " & member_count & " objects")
        group_count+=1
        theUfSession.Obj.CycleObjsInPart(workPart.Tag, NXOpen.UF.UFConstants.UF_group_type, objectTag)
        
    Loop While objectTag <> NULLTAG
    
End Function

UG NX 6.0.4.3

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources