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
369 Views, 8 Replies

Copying linked elements in wrong location

ICON-MIJ
Contributor
Contributor

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);
0 Likes

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

Mohamed_Arshad
Advisor
Advisor

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
0 Likes

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

ICON-MIJ
Contributor
Contributor
I tried and still the same result
0 Likes

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

Mohamed_Arshad
Advisor
Advisor

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
0 Likes

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

ICON-MIJ
Contributor
Contributor

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

0 Likes

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

Mohamed_Arshad
Advisor
Advisor

Which Element you're trying to copy?

Thanks & Regards,
Mohamed Arshad K
0 Likes

Which Element you're trying to copy?

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

ICON-MIJ
Contributor
Contributor
Scopeboxes
0 Likes

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

ICON-MIJ
Contributor
Contributor

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

0 Likes

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

Mohamed_Arshad
Advisor
Advisor

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
0 Likes

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 Design & Make Report