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 Views from a linked model to active model also copies other stuff too?

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
aclarke
899 Views, 9 Replies

Copying Views from a linked model to active model also copies other stuff too?

Hi all,

 

I am trying to understand why this is happing, and how to avoid it...

 

I am writing a macro that copies selected sheets and the views on these sheets from a linked model to my active model.

But when I copy over a ViewPlan it also brings in other stuff too.

 - Callout Head

 - Level Head

 - Callout Tags

 - Fill Patterns

 - Materials

 - Viewport Types

 

Why and is there a way to stop it? If no is there an easy way to access the IDs of these elements so I can delete them?  Because I haven't found how to access this, except for copy paste the ID's from the warning dialog and manually delete them, which I wish to avoid,

also I notice that the ScopeBox from the Link is also brought in, which is telling me that view specific elements hosted that this view are being copied, which makes sense, but the list above does not quite make sense, to me?

 

What elements are hosted to a view? To be clear, I am not wanting to copy any elements in the view, I only want to copy the view itself.  even though the scopebox is fine.  I actualy want that.

 

I havn't used any copy paste options, because it seems this only lets me either use the default or cancel to avoid seeing the dialog.

 

Thanks for any advise

 

Helpers.Functions.CopyElements(sourceDocument, destinationDocument, collection);

// Copy Elements from Source Document to Destination Document
public static void CopyElements(Document sourceDocument, Document 
destinationDocument, ICollection<ElementId> collection)
{
   ElementTransformUtils.CopyElements(
   sourceDocument, collection, destinationDocument, null, null);
}

 

 

warnings.png

 

9 REPLIES 9
Message 2 of 10
jeremy_tammik
in reply to: aclarke

Have you explored how it works manually through the end user interface before diving into the programming side?

 

I would recommend solving it there first.

 

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 3 of 10
aclarke
in reply to: jeremy_tammik

Hi Jeremy, thanks for your reply

 

Unfortunately, I haven't found a way to manually copy a view plan from a linked project to the active project, If you know how to do this manually I am interested to learn how?

 

I can however copy a view from my linked model to my active model via the API but as mentioned it brings in extra stuff that I don't want, so I am interested to know what is tied to a view that builds a view, there are parts that make up a view that are not upfront obvious.

 

I can capture the ID's manually from the exported warning, or run a script on the export but extra steps still must be taken.  So I am looking for a way to access these element ID from inside my macro remove the elements as part of my macro vs. a manual step at the end.  I am trying to avoid bringing in extra stuff.

 

Thanks for any advise.

Message 4 of 10
jeremy_tammik
in reply to: aclarke

I have no idea whatsoever how to achieve anything manually at all. I deal with the API only.

 

However, I just noticed this comment that describes one way to remove elements from a view:

 

https://thebuildingcoder.typepad.com/blog/2018/03/boston-forge-accelerator-and-aligning-plan-views.h...

   
Alternate suggestion: I have found that by temporarily completely clearing both Views of any content (achieved by way of swapping a ViewTemplate in my case)...

   

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 5 of 10
RPTHOMAS108
in reply to: aclarke

Most those things are related to the viewports and views you are copying from one sheet to another:

 

If you are copying section views / callouts then they will have call out tags and section tags.

Such tags have solid fills sometimes (the black parts)

Materials that is a strange one but probably comes from the families being copied i.e. all families have some materials (even those for annotations).

Viewports will have viewport types, that's a given.

 

Look within the families and you find most of these items i.e. level heads may exist in a callout tag family but isn't used perhaps (general purpose family).

 

You may start missing some of these things if you start removing them. If a view is set to a scopebox then how can that be maintained without one e.g. view rotation? Dependencies are copied.

 

Try also ElementTransformUtils.CopyElement(View, ICollection(ElementId), View, Transform, CopyPasteOptions)

Since viewports are view specific.

 

More importantly use CopyPasteOptions.SetDuplicateTypeNamesHandler.

 

Message 6 of 10
RPTHOMAS108
in reply to: RPTHOMAS108

CopyPasteOptions.SetDuplicateTypeNamesHandler.

 

You get a list of duplicate names and TypeIds. Yes you have to cancel or use defaults but who says you can't do the same paste operation more than once?

 

If duplicates found: store affected types, cancel the operation, rename existing types, paste again.

Then you have both new and existing types.

If you then want same new type for all: just use change type id for all existing elements that used those old types and delete the old types.

 

Message 7 of 10
aclarke
in reply to: RPTHOMAS108

Thanks Thomas

 

I failed to connect the dots.

- A View is hosted to a level, hence Level Heads

- If I delete a Callout, this deletes the view, so the view is also hosted to the Callout, hence the Callout Head

- Both the Level Head and the Callout Head have Filled Regions, hence the Filled Regions

- Because the view is on a sheet already, even though I am not copying the sheet, the view still carries this viewport, hence the Viewport Types

- I'm not sure about where the Material is coming from but now I see the logic, I will find it.

 

If I copy more than one view at a time, then the above will happen.

 

 

Thanks for your help Thomas...

 

 

Message 8 of 10
aclarke
in reply to: jeremy_tammik

Hi Jeremy

Out of curiosity, why would you suggest for me to try something that you say, "you have no idea how to do"?

How is this helpful?

 

Message 9 of 10
jeremy_tammik
in reply to: aclarke

Hi Alan,

 

Sorry for not expressing precisely what I meant.

 

I meant to say that I do not know how to address this in the user interface, and it normally helps solve a programming task if you know how to achieve your goal manually.

 

I then went on to search for other solutions that I have no personal experience with, hoping that might help.

 

Please excuse me if that was not the case.

  

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 10 of 10
aclarke
in reply to: jeremy_tammik

Hi Jeremy

Thank you for your follow up.  and the link you provided.  Please forgive me, when you told me you had no experience, your first post seemed a bit pointless and I wanted to understand why.  I'm in the user interface everyday and I try everything manually before programmatically, I really thought you knew how to do it manually and I was about to be enlightened only to become baffled.

 

Thank you for all your efforts.

 

 

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community