See the top rated post in this thread. Click here

Results 1 to 8 of 8

Thread: ApplyTemplate method, anyone used it?

  1. #1
    100 Club
    Join Date
    2007-10
    Location
    Brisbane
    Posts
    138
    Login to Give a bone
    0

    Default ApplyTemplate method, anyone used it?

    This is in the CHM file, and in intellisense but not much else is documented on it anywhere from what i can tell, not used in SDK sample, not in webcast labs, and nothing on google.

    It seems simple, ApplyTemplate(viewtemplate as view). The problem I'm having, is how do I select my viewtemplate?

    In revit when you try to apply a view template it shows you a list, how do I create myself a list like that?

    Lets say for example, we have a view template called: "BW_Masonry Plan" I can see this as an element, with no category or other information. So I try to cast is as an Autodesk.Revit.Elements.View. This nulls it.

    If I loop through all of the View elements in the document, BW_Masonry Plan never shows up.

    So how is it that I can define that element as my view template?

    Heres some code I've been trial and erroring, it's not well formed I realise that (I will clean it up as per the element efficiency thread) but I'm just trying things to get it to return a view.

    private View GetAllViews(Document doc)
    {
    string ViewsList = " ";

    ElementIterator itor = doc.Elements;
    itor.Reset();

    while (itor.MoveNext())
    {
    Element curelem = itor.Current as Autodesk.Revit.Element;
    // Autodesk.Revit.Elements.View curelem = itor.Current as Autodesk.Revit.Elements.

    if (null == curelem)
    {
    continue;

    }
    else
    {
    if (curelem.Name == "BW_Masonry Plan")
    {
    ViewsList += curelem.Name.ToString();
    ViewsList += " ";
    if (curelem.Category != null)
    ViewsList += curelem.Category.Name.ToString();

    ViewsList += " ";
    if (curelem.ObjectType != null)
    ViewsList += curelem.ObjectType.Name.ToString();
    View ViewTemp = curelem as View;
    return ViewTemp;
    }
    }

    }
    WF.MessageBox.Show("returning null");
    return null;

    }

    Can anyone shed any light? Thanks!

  2. #2
    AUGI Addict
    Join Date
    2003-11
    Location
    New Zealand
    Posts
    1,116
    Login to Give a bone
    0

    Default Re: ApplyTemplate method, anyone used it?

    Rod,

    Yeah, it's a little confusing.

    You use a existing view and it applies the graphical overrides etc from that view. It's been a while since I used it but from memory it works OK. I can dig out some code if you don't have any luck.

    The element object you found doesn't refer to a view template that you can use currently. There are some parameters for scale etc which you can set on the view you're wanting to apply the template to.

    Guy

  3. #3
    I could stop if I wanted to
    Join Date
    2007-08
    Posts
    322
    Login to Give a bone
    0

    Default Re: ApplyTemplate method, anyone used it?

    Just a quick caution about view templates. They will dump any of your overrides in the view. I find that they are really only worth wile at the inception of the view and only serve to create problems when applied later.
    I am not sure exactly what you are trying to do but it may be easier to set up your view templates in a template file and adjust them there.

    I tired applying view templates after we had done some work on interior elevations (so that I wouldn't have to hide everything in each view). Well the short of it is that it un-hid everything in the view (ie we had specifically hid certain walls in views because the room was L shaped, etc), changed all of the scales, and overrode my visibility graphics overrides.

    Now We just use view templates at the initial creation of views. As we realize that certain things should be added/ removed from the view template then I go back and edit our template for future use.

    Not that this solves your API issue....
    HTH

    Nick

  4. #4
    100 Club
    Join Date
    2007-10
    Location
    Brisbane
    Posts
    138
    Login to Give a bone
    0

    Default Re: ApplyTemplate method, anyone used it?

    Quote Originally Posted by GuyR View Post
    Rod,

    Yeah, it's a little confusing.

    You use a existing view and it applies the graphical overrides etc from that view. It's been a while since I used it but from memory it works OK. I can dig out some code if you don't have any luck.

    The element object you found doesn't refer to a view template that you can use currently. There are some parameters for scale etc which you can set on the view you're wanting to apply the template to.

    Guy
    I see, so you can't actually use "View Templates"(which show up in the 'apply view templates' menu) there, you just have to use another "View" as a "template" ?

    NKramer, thanks for that warning, I'll have a talk to our drafters and see if view templates are really the way we want to go.

    If not, then editing the scale etc of the active view is what I'll continue doing.

    Thanks

  5. #5
    100 Club jamie.casile80054's Avatar
    Join Date
    2004-12
    Location
    rock in the middle of the Pacific
    Posts
    191
    Login to Give a bone
    0

    Default Re: ApplyTemplate method, anyone used it?

    Aloha,
    I may be way off base here, but just in case... the View Templates can be accessed in the Settings pulldown menu.
    you can make a view template from another view, but i believe the theory on that is that you went through the process of changing things so that it is right in one view, and now you want the same changes made to all other similar views. so you save the changes for that view as a view template.
    if you check the view properties of a view, the Default View Template is listed there. you can scroll and pick one to apply to the view as well.
    whatever view template is 'assigned' in the Default View Template is what is used when you 'update' your view templates. so, if you use the settings menu > View Templates and change the scale of a specific template - this will NOT automatically override everything. you have to reapply it to the view so it updates. if you right-click in the proj browser and Apply View Template, and select the <Default View Template> it will update the view template currently assigned to the view you have selected. if there is no previously selected view template, nothing updates.
    Hope this makes sense.
    good luck,
    jamie
    Jamie Casile
    CAD/BIM Manager
    Pacific CADD Services, Inc.
    ...My Lomography Page...

  6. #6
    100 Club mschroeder's Avatar
    Join Date
    2005-06
    Location
    Boston
    Posts
    154
    Login to Give a bone
    0

    Default Re: ApplyTemplate method, anyone used it?

    Quote Originally Posted by r.howarth View Post
    I see, so you can't actually use "View Templates"(which show up in the 'apply view templates' menu) there, you just have to use another "View" as a "template" ?
    Have you found a way to use a view template (not just another view) in the ApplyViewTemplate() method? I can't find a view template instance through the API.

  7. #7
    100 Club
    Join Date
    2004-02
    Location
    Brookline, MA
    Posts
    186
    Login to Give a bone
    1

    Default Re: ApplyTemplate method, anyone used it?

    Nope - I'm pretty sure you can't use ViewTemplates. It is technically possible to find them (they are "Element" objects) - but you can't use them.

    The ApplyTemplate() only works with existing views.
    -Matt

  8. #8
    100 Club
    Join Date
    2007-10
    Location
    Brisbane
    Posts
    138
    Login to Give a bone
    0

    Default Re: ApplyTemplate method, anyone used it?

    Unfortunately no I didn't find a way, I did hear something from autodesk about them planning on fixing this but I haven't had a good look to see if they did it for 2010 (my guess is no though as its not in the change list)

    As Matt Said, You can use another view as a template, but can't apply a viewtemplate as i couldn't find a way to retrieve the viewtemplates as an object that inherits from view.
    Last edited by r.howarth; 2009-04-03 at 04:51 AM.

Similar Threads

  1. What method should I use?
    By Anthony Rhodes in forum AutoCAD Civil 3D - Grading
    Replies: 2
    Last Post: 2011-07-25, 05:24 PM
  2. What is your method?
    By sandeep_koodal in forum Training
    Replies: 5
    Last Post: 2009-08-19, 10:06 PM
  3. Is any method to export ucs...?
    By sibuayyappan in forum AutoCAD General
    Replies: 5
    Last Post: 2009-01-29, 10:43 AM
  4. Project method
    By ASHISH_SHAH in forum AutoCAD Electrical - General
    Replies: 0
    Last Post: 2005-06-16, 11:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •