Notifications
Clear all

[Closed] Can't find open group head to close

 MZ1

I got this annoying error “Can’t find open group head to close” when I want to create assembly. I guess this happen when I change parent of any group member to another object. How we can fix this?

3 Replies
 MZ1

Now, I realized why this happen. When we link last member of an open group to another object, grouphead dummy will be remain in the scene:

(
	fn CreateGroup Objs Name:"GroupHead" SetOpen:false = 
	(
		BeforeGroup = Objects as array
		group Objs name:Name
		local Head = undefined
		for o in Objects where finditem BeforeGroup o == 0 while Head == undefined do Head = o
		if isvalidnode Head and SetOpen == true do setGroupOpen Head true
		Head
	)
	
	delete objects
	Obj = sphere()
	GroupHead = CreateGroup #(Obj) SetOpen:true
	ParentObj = box pos:[100,0,0]
	Obj.parent = ParentObj
	
	clearlistener()
	assemblyMgr.canassemble objects
)
	
 MZ1

This function works but I don’t know why I have to run it multiple times to make it work.

(
	fn IsHead Obj = 
	(
		isgrouphead Obj or isopengrouphead Obj
	)
	
	fn IsMember Obj = 
	(
		isgroupmember Obj or isopengroupmember Obj
	)
	
	fn ClearUnusedGroups =
	(
		for o in objects where IsMember o and not IsHead (P = o.parent) do
		(
			detachNodesFromGroup o
			o.parent = P
		)
		for o in objects where IsHead o and o.children.count == 0 do explodegroup o
	)
	
	for i = 1 to 4 do ClearUnusedGroups()
	clearlistener()
	assemblyMgr.canassemble objects
)
	

if you read this thread till the end, you get the solution for sure

http://forums.cgsociety.org/showthread.php?f=98&t=1224794&page=1&pp=15