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!

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

Status
Not open for further replies.

DQuick

Aerospace
Dec 8, 2010
8
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
 
Replies continue below

Recommended for you

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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor