Is there a batch method for placing adaptive component points?

Is there a batch method for placing adaptive component points?

Anonymous
Not applicable
2,094 Views
10 Replies
Message 1 of 11

Is there a batch method for placing adaptive component points?

Anonymous
Not applicable

Hello there, 

 

I already wrote concerning my problem in a different thread but was able now to figure out that the bad performance is relied to movement of adaptive components.

As far as I understand adaptive components are placed on default points and then have to be moved via code to the corresponding position. Because I am working with gauss krüger coordinates this is quite a distance...

I found another thread here giving the solution of only assigning the corresponding coordinates but this does not work in Python? (e.g. point.Position = refpt)

 

My questions:

Is there a different approach of placing the adaptive family straight on the desired points?

Or is there a possibility to batch the movement of points? I found the method FamilyInstanceCreationData(famsymb,iList)but could not make it run in python nor figure out whether it is only for single point families.

I am working with RPS, below please see my code.

 

 Any help would be greatly appreciated!

 

 

My approach is the following:

# place family instance, get default placement points, subtract from my desired coordinates (list) and move element

 

inst = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(

        doc, inst)

placePointIds = []

placePointIds = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(

        inst)

for ind, item in enumerate(placePointIds):

     # assign a point object to refpt, refpt is the orginal point of the family, newpt the new point derived from pt information

        refpt = doc.GetElement(item)

        newpt = pt[ind]

        trans = newpt.Subtract(refpt.Position)

        ElementTransformUtils.MoveElement(doc, item, trans)

 

0 Likes
Accepted solutions (2)
2,095 Views
10 Replies
Replies (10)
Message 2 of 11

Revitalizer
Advisor
Advisor

Hi,

 

there is a performance problem with ElementTransformUtils:

https://forums.autodesk.com/t5/revit-api-forum/elementtransformutils-performance-issue/m-p/5775624/h...

Seems to auto regenerate after each movement.

 

Did you see the AdaptiveComponentInstanceUtils.MoveAdaptiveComponentInstance method?

 

Perhaps this one does not include a regenerate, I don't know.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 3 of 11

FAIR59
Advisor
Advisor

the placement points are ReferencePoints. Maybe you can use :  (refpt as ReferencePoint).SetCoordinateSystem()

0 Likes
Message 4 of 11

jeremytammik
Autodesk
Autodesk

Hi guys,

 

Happy New Year to you!

 

Thank you for pointing out the old thread, Rudi.

 

I prompted the development team for a status update on REVIT-74636 [ElementTransformUtils performance].

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 11

Anonymous
Not applicable

Hey thanks a lot for all the suggestions!

@Revitalizer: I had tried using MoveAdaptiveComponentInstance for the first point of my adaptive component for at least moving it more to the direction of its final placement. The other points were still transformed using 'MoveElement'.

 

Now I changed all points to be transfered via 'MoveAdaptiveComponentInstance' but now I only get the error message there are "multiple instances on one point which will be counted twice in schedules..." but no adaptive Component is created.

 

Even using the 'MoveAdaptiveComponentInstance' Method all points are being moved one by one, originally I was assuming whether there would be a batch/list method to move them all at once per instance?

 

@FAIR59: What do you mean precisely with using the reference point? I tried to assign the values directly , e.g. refpt.Position = newPoint, but that does not work.

 

Below please find my code:

 

# create new instance of adaptive component family
inst = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(
doc, famsymb)
placePointIds = []
placePointIds = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(
inst)
for ind, item in enumerate(placePointIds):
## assign a point object to refpt, refpt is the orginal point of the family, newpt the new point derived from pt/LOC inf
refpt = doc.GetElement(item)
newpt = pt[ind]
trans = newpt.Subtract(refpt.Position)
print trans
print 'ind: ' + str(ind)

## if else statement for using both methods, moveInstance for first point, moveElement for following ones
#if ind == 0:
transform = Transform.CreateTranslation(trans)
AdaptiveComponentInstanceUtils.MoveAdaptiveComponentInstance(
inst, transform, 'false')
#else:
#ElementTransformUtils.MoveElement(doc, item, trans)

0 Likes
Message 6 of 11

FAIR59
Advisor
Advisor
Accepted solution

I mean you can use the SetCoordinateSystem method of the referencepoint like this:

 

				Element refpt = doc.GetElement(item);
				XYZ newpt = pt[ind];
				Transform tf = Transform.Identity;
				tf.Origin = newpt;
				(refpt as ReferencePoint).SetCoordinateSystem(tf);

 

0 Likes
Message 7 of 11

Anonymous
Not applicable

Yes ok, as far as I understand that assigns my new point directly to the reference point? But still I will have to move each point which causes the bad performance no?

 

0 Likes
Message 8 of 11

FAIR59
Advisor
Advisor
Accepted solution

Yes, you have to move every point separate. If the bad performance issue is related to the ElementTransformUtils methods, as suggested, then this method might give better performance. To know for sure, you'd have to test.

0 Likes
Message 9 of 11

Anonymous
Not applicable

Hey awesom!!! It works! Performance is way better and the code runs fluid! I suppose this is even better than moving components alsthough I would be interested to compare both methods once it is fixed...

 

I read the API doc but I don't really understand what the Transform.Identity does... could you give me a hint?

Thanks a lot for your efforts, really saved my day 😃

 

My code looks now like this:

 

placePointIds = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(
inst):


for ind, item in enumerate(placePointIds):
refpt = doc.GetElement(item)
newpt = pt[ind]
tf = Transform.Identity
tf.Origin = newpt
refpt.SetCoordinateSystem(tf);

0 Likes
Message 10 of 11

Anonymous
Not applicable

Hi,

 

Your code is for the placement the family or move the adaptive point after placement the family?

 

Thank you!


0 Likes
Message 11 of 11

Anonymous
Not applicable
Hey there, by now I learnt to first place the points at default and then move the points accordingly. More efficient and quicker. Hope that helps!
0 Likes