Apply Dependent Views

Apply Dependent Views

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

Apply Dependent Views

Anonymous
Not applicable

Hello everybody!,

 

I am developing a tool to duplicate complete view sets with its depending views and also I would like to compi the view reference tags. using the revit interface, the way to do it is by the option "Apply Dependent Views"

Captura de pantalla 2016-02-20 a las 20.54.00.png

 

 

So far I have been able do duplicate views and create dependent views using "view.Duplicate(ViewDuplicateOption.Duplicate) and  view.Duplicate(ViewDuplicateOption.AsDependent)".

Unfortunately I have not managed to apply the dependent views to a new view using the API.

Is there any method that I am loosing?

 

Thanks in advance!!

0 Likes
2,145 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable

Hello again,

 

As I am almost convinced that is there not a way to manage View references through the API, I tried to do it by myself:

  • copying the view references from the original to the new view.
  • getting the target view paramater and building a new string with the new one
  • trying to change the target view parameter...... Oh no! it is a Read Only parameter!!!

I leave here the code just in case you have a better idea. But I am affraid we can not do it via API 😞

 

//Collect all view references in the view duplicated
FilteredElementCollector vRC = new FilteredElementCollector(doc,v.Id);
vRC.OfCategory(BuiltInCategory.OST_ReferenceViewer);

//Add all view references id's to  list
List<ElementId> lVRI = new List<ElementId>();
foreach (Element e in vRC)
{
	lVRI.Add(e.Id);
}

//Check if there are view references in the duplicated view & if the new view is not a dependent view
if (lVRI.Count > 0 && pV.IntegerValue == -1)
{
	//Copy all view references from the original view to the new one
	ElementTransformUtils.CopyElements(v,lVRI,nV,Transform.Identity,new CopyPasteOptions());
	
	//collect al view references coied to the new view
	FilteredElementCollector nVRC = new FilteredElementCollector(doc,nV.Id);
	nVRC.OfCategory(BuiltInCategory.OST_ReferenceViewer);
	foreach (Element e in nVRC)
	{
		//Get target view and change it to the new target view
		Parameter p = e.get_Parameter(BuiltInParameter.REFERENCE_VIEWER_TARGET_VIEW);//**READ ONLY**
		string tV = p.AsValueString();
		string nTV = nV.Title;
		string[] tVSp = tV.Split('-');
		string nDVN = tVSp.Last().Substring(1);
		nTV = nTV + " - " + nDVN;
		p.Set(nTV);
	}
}

Regards!

0 Likes
Message 3 of 11

Anonymous
Not applicable

Hello,

Sorry for fefloat this topic.

 

Anyone can give an idea about it?

 

Thanks!

0 Likes
Message 4 of 11

jeremytammik
Autodesk
Autodesk

Dear Chema78,

 

I am looking at this...

 

Here is another not-very-helpful related thread that I happened to come across:

 

http://forums.autodesk.com/t5/Autodesk-Revit-API/Is-Context-Menu-accessible-through-API/td-p/3228382

 

I passed on the question to the development team.

 

Hopefully more anon...

 

Cheers,

 

Jeremy



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

0 Likes
Message 5 of 11

Anonymous
Not applicable

Thanks Jeremy,

whay a pity not being able to apply dependend views with revit API 😞

 

Is there any wish where I can write to Autodesk to request it?

 

Thanks!

0 Likes
Message 6 of 11

jeremytammik
Autodesk
Autodesk

Dear Chema78,

 

Yes, you can always submit a wish list item right here in the forum.

 

Do not give up until you actualy have the true final confirmed number of the development issue submitted for you.

 

However, in this case, please do not give up so fast!

 

I have not heard back from the development team, but I found some promising results on the Internet:

 


I searched for [revit api apply dependent view](https://duckduckgo.com/?q=revit+api+apply+dependent+view) and quickly found a suitable solution for you, I hope.

 

This can indeed be achieved programmatically, as asserted for the [Apply Dependent Views tool](http://ideatesolutions.blogspot.ch/2011/09/i-wish-we-had-known-this-earlier.html), part of a Revit Consulting engagement at Ideate Inc.

 

[Saikat Bhattacharya](http://adndevblog.typepad.com/aec/saikat-bhattacharya.html), ex-ADN, now an Autodesk Technical Consultant, explains how in his discussion on [creating a New ViewPlan in a family document](http://adndevblog.typepad.com/aec/2012/09/creating-a-new-viewplan-in-a-family-document-using-the-rev...

 

"... use the `View.Duplicate` method to create a duplicate of the view. When using this method, you can specify three options for the duplication method via the `ViewDuplicateOption` enumeration and thus imitate the functionality available in the UI &ndash; which is to create a duplicate, duplicate with detailing and duplicate as dependent. Once the view has been duplicated, the parameters of the new view can be altered &ndash; the snippet below shows how we can change the name, for example."

 

I suggest you try that out and let us know how it goes for you.

 

Good luck!

 

Cheers,

 

Jeremy



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

0 Likes
Message 7 of 11

jeremytammik
Autodesk
Autodesk

I heard back from the development team.

 

Quite a discussion ensued.

 

Apparently, they agree that we do not have API access to this functionality, and that we should, so a wish list item was created for it:

 

REVIT-86666 [Expose 'Apply Dependent Views' functionality to API]

 

I hope this helps.

 

Cheers,

 

Jeremy



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

Message 8 of 11

Anonymous
Not applicable

Thanks so much Jeremy!

 

I will wait for this new option!!!

0 Likes
Message 9 of 11

Anonymous
Not applicable

We too are attempting to do 'Apply dependents' through the API

 

So please add my vote for the wish list item:

REVIT-86666 [Expose 'Apply Dependent Views' functionality to API]

 

An alternate approach:

'Apply dependents' can be almost duplicated in the current (2018.1) API by:

1) Creating new dependent views on the new parent view using:

        View.Duplicate(newParentView, ViewDuplicateOption.AsDependent)

2) Copy apply view properties (scope box, etc) from original dependent view to new dependent view

 

This almost works except the API does support copying and editing ViewReferences:

1) ElementTransformUtils.Copy() crash Revit when used with ViewReference elements

2) ReferenceableViewUtils class methods throw an exception when used with ViewReference elements

 

So let me add wishes 2 & 3:

Allow ElementTransformUtils.Copy() and ReferenceableViewUtils to work with ViewReference.

 

Thanks,

Ben Bishoff

0 Likes
Message 10 of 11

jeremytammik
Autodesk
Autodesk

Dear ben,

 

Thank you for re-raising this and for your half workaround.

 

I added your input and wish to the database entry REVIT-86666 [Expose 'Apply Dependent Views' functionality to API] and prompted the development team for a status update on it.

 

Cheers,

 

Jeremy



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

Message 11 of 11

Anonymous
Not applicable

Thanks Jeremey for your ever prompt responses!

 

Cheers,
Ben

0 Likes