Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Copying linked elements in wrong location

8 REPLIES 8
Reply
Message 1 of 9
ICON-MIJ
316 Views, 8 Replies

Copying linked elements in wrong location

Hi All,

 

following a discussion here. im experiencing odd result . The copied elements are not in the same location as the linked mo...

Copy.png

 

Reference reference = uidoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element);

                RevitLinkInstance revitLinkInstance = doc.GetElement(reference) as RevitLinkInstance;

                Document sourcedocument = revitLinkInstance.GetLinkDocument();

                ICollection<ElementId> linkedElements = new FilteredElementCollector(sourcedocument)
                .OfCategory(BuiltInCategory.OST_VolumeOfInterest)
                .WhereElementIsNotElementType().ToElementIds();

                CopyPasteOptions copyOptions = new CopyPasteOptions();
                copyOptions.SetDuplicateTypeNamesHandler(new CopyUseDestination());
               
                ElementTransformUtils.CopyElements(sourcedocument, linkedElements,doc, revitLinkInstance.GetTotalTransform(), copyOptions);
8 REPLIES 8
Message 2 of 9
Mohamed_Arshad
in reply to: ICON-MIJ

HI @ICON-MIJ 

Kindly use Transform.Identity instead of GetTotalTransform()

 

ElementTransformUtils.CopyElements(sourcedocument, linkedElements,doc, Transform.Identity, new CopyPasteOptions());

Hope this will Helps 🙂

Thanks & Regards,
Mohamed Arshad K
Message 3 of 9
ICON-MIJ
in reply to: Mohamed_Arshad

I tried and still the same result
Message 4 of 9
Mohamed_Arshad
in reply to: ICON-MIJ

Have you tried by removing the CopyPasteHandler?, Create Directly by new CopyPasteOptions().
And Which element you're trying to copy?

Thanks & Regards,
Mohamed Arshad K
Message 5 of 9
ICON-MIJ
in reply to: Mohamed_Arshad

I tried the following:
1. Copy without handler
2. Manual Copy form document to document via UI
3. Via Dynamo



and none works for me...very strange..I'm copying scope boxes

Message 6 of 9
Mohamed_Arshad
in reply to: ICON-MIJ

Which Element you're trying to copy?

Thanks & Regards,
Mohamed Arshad K
Message 7 of 9
ICON-MIJ
in reply to: Mohamed_Arshad

Scopeboxes
Message 8 of 9
ICON-MIJ
in reply to: ICON-MIJ

It's working on other elements such as walls, floors, furnitures but not on Scopeboxes

Message 9 of 9
Mohamed_Arshad
in reply to: ICON-MIJ

No For me its Wokring Fine. I use same code only.

Reference GIF:
Demo.gif


            Reference reference = revitUIDoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element);

            RevitLinkInstance revitLinkInstance = doc.GetElement(reference) as RevitLinkInstance;

            Document sourcedocument = revitLinkInstance.GetLinkDocument();

            ICollection<ElementId> linkedElements = new FilteredElementCollector(sourcedocument)
            .OfCategory(BuiltInCategory.OST_VolumeOfInterest)
            .WhereElementIsNotElementType()
            .ToElementIds();


            using (Transaction createTransaction = new Transaction(doc, "Create Transaction"))
            {
                createTransaction.Start();

                ElementTransformUtils.CopyElements(sourcedocument, linkedElements, doc, Transform.Identity, new CopyPasteOptions());

                createTransaction.Commit();
            }



 

Thanks & Regards,
Mohamed Arshad K

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community