Display Names Script

I took this code from Autodesk Help, the code is displaying names of objects in viewport, and I have two questions about how to improve it.
The first question is: I have a group of objects, script shows me the names of every object in this group, but I want it to show me just the name of the group, how to do this?
And the second question is: When script displays the name of camera, it also displays the name of camera target, but I don't want it. How to exclude taget name? I tried something like "if o != Targetobject", but it not helped.

And here is the code:

unregisterRedrawViewsCallback GW_displayObjectNames

fn GW_displayObjectNames =
(
gw.setTransform (matrix3 1)
for o in objects where not o.isHiddenInVpt do
gw.text o.pos o.name color:yellow
gw.enlargeUpdateRect #whole
)

registerRedrawViewsCallback GW_displayObjectNames

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sketchupmaster's picture

error

Hi

When Daylight system active in view-port then showing message
"Unkonwn property: "po" in $Daylight System"

Thanks,
Sketchup Master

miauu's picture

.

Try this. The text will be displayed at the object's center.

unregisterRedrawViewsCallback GW_displayObjectNames
 
	function FindTopMostGroupHead obj = 
	(
		while obj != undefined and (not isGroupHead obj or isGroupMember obj) do
			(obj = obj.parent)
		obj
	)
 
	fn GW_displayObjectNames =
	(
		gw.setTransform (matrix3 1)
		for o in objects where not o.isHiddenInVpt and classof o != Targetobject do
		(
			if isGroupHead o or isOpenGroupHead o or isGroupMember o or isOpenGroupMember o then
			(
				grpHead = FindTopMostGroupHead o
				gw.text grpHead.center grpHead.name color:yellow
			)
			else
			(				
				gw.text o.center o.name color:yellow				
			)
			gw.enlargeUpdateRect #whole
		)
	)
 
	registerRedrawViewsCallback GW_displayObjectNames
miauu's picture

.

	unregisterRedrawViewsCallback GW_displayObjectNames
 
	function FindTopMostGroupHead obj = 
	(
		while obj != undefined and (not isGroupHead obj or isGroupMember obj) do
			(obj = obj.parent)
		obj
	)
 
	fn GW_displayObjectNames =
	(
		gw.setTransform (matrix3 1)
		for o in objects where not o.isHiddenInVpt and classof o != Targetobject do
		(
			if isGroupHead o or isOpenGroupHead o or isGroupMember o or isOpenGroupMember o then
			(
				grpHead = FindTopMostGroupHead o
				gw.text grpHead.pos grpHead.name color:yellow
			)
			else
			(				
				gw.text o.pos o.name color:yellow				
			)
			gw.enlargeUpdateRect #whole
		)
	)
 
	registerRedrawViewsCallback GW_displayObjectNames
chooj's picture

working

It is working! Thanks!

miauu's picture

.

This is more compact version and will show the names of the nested groups.

unregisterRedrawViewsCallback GW_displayObjectNames
 
	fn GW_displayObjectNames =
	(
		gw.setTransform (matrix3 1)
		for o in objects where not o.isHiddenInVpt and classof o != Targetobject do
		(
			if isGroupHead o or isOpenGroupHead o then
			(
				gw.text o.pos o.name color:yellow
			)
			else
			(
				if not isGroupMember o and not isOpenGroupMember o do
					gw.text o.pos o.name color:yellow				
			)
			gw.enlargeUpdateRect #whole
		)
	)
 
	registerRedrawViewsCallback GW_displayObjectNames
sketchupmaster's picture

toggle . . . . !

Hello sir,

thanks for this. . . .
can we do only selected group toggle?

Thanks,
Sketchup Master

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.