Notifications
Clear all

[Closed] Reading modifiers from xRefs

Hello again to all.
I need to get ClassInstances of a modifier in the scene (let’s say ‘bend’ modifier).

1.- For objects in the scene, it’s easy:

	BendModifs = (getclassinstances bend)

2.- For objects in an xrefered scene, it’s easy too (just one level. For more levels, I should use a recursive function):

	for i = 1 to (xrefs.getXRefFileCount()) do
	(
		root1 = (xrefs.getXRefFile i).tree
		append BendModifs (getClassInstances bend target:root1)
	)

3.- For xRef Objects, I have no idea. Anyone can help me?

	for i = 1 to (objXRefMgr.recordCount) do
	(
		a = objXRefMgr.GetRecord i
		for j = 1 to a.ItemCount #XRefObjectType do
		(
			b = a.GetItem j #XRefObjectType
			append BendModifs (getClassInstances bend target:b)
		)
	)

Doesn’t work at all. I can’t understand well what an xRef Object is and how to work with.
Thanks in advance.

4 Replies

Ok, I have a possible solution:

3.- For xRef Objects (just one level, non recursive):

	xRefObjectsInScene = getclassinstances xrefobject
	for xrf in xRefObjectsInScene do
	(
		xrf.getsourceobject false modifiers:&xrfModifs
		for m in xrfModifs do
		(
			if classof m == bend do append BendModifs m
		)
	)

By the way, what does mean the ‘&’ I have to write before the modifiers array ‘&xrfModifs’?

I think the & comes from it’s use in c++

variable it references

Thanks, @AngryBear.
It’s been hard until I decided to write the ‘&’ and then it worked!

‘&’ means pointer to a variable.

fn setAValue &a value = (a = value)

a = 1
setAValue &a 2
print a

please let me know if it doesn’t work.