ViewDrafting : missing ViewFamilyType

ViewDrafting : missing ViewFamilyType

Anonymous
Not applicable
870 Views
5 Replies
Message 1 of 6

ViewDrafting : missing ViewFamilyType

Anonymous
Not applicable

Hi Folks,

 

In a custom plugin, I have to create a new Drafting View, and I do the following :

var vft = new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType)).Cast<ViewFamilyType>().FirstOrDefault(t => t.ViewFamily == ViewFamily.Drafting);
var draft = ViewDrafting.Create(doc, vft.Id);

 

This worked like a charm, until I found a customer's project that didn't contained any ViewFamilyType of type Drafting.

It seams to be a fatal issue, because :

- Second argument is mandatory (i.e cannot be NULL nor ElementId.Invalid) in ViewDrafting.Create(doc, id)

- There is no API call to create a ViewFamilyType from scratch (Duplicate is not suitable because there is no element to duplicate ...)

 

Am I toasted ?

Thanks for help 🙂

0 Likes
Accepted solutions (1)
871 Views
5 Replies
Replies (5)
Message 2 of 6

TripleM-Dev.net
Advisor
Advisor

Hi,

 

The ViewFamily's always contain at least one type, the last one can't be purged or deleted.

I've tested if the last one could be deleted by the API, it can't.

So there's something wrong.corrupt with the document.

 

I always build in a check if it's a valid ElementId (compare against ElementId.InvalidElementId).

And if it's invalid give the user a message something is corrupt/missing in the document.

(copy a draftview from another project to get a drafting type back.)

 

I wonder, can you create a Draft view in the UI if there's no Drafting type?

 

- Michel

 

 

0 Likes
Message 3 of 6

TripleM-Dev.net
Advisor
Advisor
Accepted solution

See this post, fault in a certain language template:

https://forums.autodesk.com/t5/revit-api-forum/drafting-view/td-p/6300235 

 

 

0 Likes
Message 4 of 6

Anonymous
Not applicable

The document contains many ViewFamilyType, but none of type ViewFamily.Drafting.

And yes, by means of direct Revit UI manipulation, I can create a new Draft View despite the fact that no ViewFamilyType of type Drafting is present.

0 Likes
Message 5 of 6

TripleM-Dev.net
Advisor
Advisor

And after the DraftView is created by the UI, then a type exists?

If so, just report the User a Type is missing and to create one by the UI. (possibly state the Fault in certain Templates

 

And would be good that those Templates/projects get fixed.

 

- Michel

0 Likes
Message 6 of 6

Anonymous
Not applicable

After manual Draft View creation, there is no new ViewFamilyType, but I can use View.Duplicate().

 

The missing type in French (at least) Template is an old topic (2016).

The faulty project is from Rvt2020, but I guess it is from an updated Rvt2016 initial project, created with the faulty template, hence the missing types.

 

0 Likes