Create Sheet from AssemblyInstance

Create Sheet from AssemblyInstance

Anonymous
Not applicable
4,643 Views
7 Replies
Message 1 of 8

Create Sheet from AssemblyInstance

Anonymous
Not applicable

Hey all, I've been digging and looking and trying to find a hint as to how to do this, but I'm not having any luck.  I wrote a tool to essentially overwrite the "Create Assembly Instance" button in the Modify tab, with a little extra added on to it.  What I'm trying to accomplish is to take the AssemblyInstance I just created and create a new Sheet with several Views from it.  Essentially something like this:

 

SpoolSheet_Example.png

 

I have a couple Families that I've created to populate the data, and Shared Parameters as the data.  I'm just not sure how to create the whole thing with the Iso, Side and Top-Down views.  Do I need to create the whole sheet as a Family, and have it inherit the other Families and views?  If so, would creating that be like creating other Families, or is there something special I need to do?  

 

Any guidance is a huge help.  I've been stuck on this for a couple days.

 

0 Likes
Accepted solutions (1)
4,644 Views
7 Replies
Replies (7)
Message 2 of 8

RPTHOMAS108
Mentor
Mentor

Presumably you are using the static methods within AssemblyViewUtils to create the sheet and the views. Perhaps highlight where you are getting stuck with this or in general? To be honest I've not used these utilities, there seems to be a function for creating a sheet and various functions for creating different types of view that logically have to appear on that 'assembly' sheet. However there is nothing related to viewport placement on the sheet for the view so presumably you have to find the sheet and the views after they are created and place them in the conventional way.

 

From a Revit user perspective aren't assemblies just a collection of Elements grouped together and optionally displayed on a sheet with detail views? With the assembly used in different places similar to blocks in AutoCAD? The disadvantage to AutoCAD blocks being that changing one assembly instance makes it a new assembly distinct from the others instead of changing the others?

 

I'm not sure families need to be specifically created, in the UI I would just be selecting elements and picking the 'make assembly button'.  Then I'd be selecting 'make assembly views' before placing them on the sheet.

0 Likes
Message 3 of 8

Anonymous
Not applicable

Thanks for the input.  To answer some of your questions:  I'm not using those methods - but that's because I didn't know about them, so thanks for that!

 

Yes, an AssemblyInstance is just a collection of Elements.  I don't know how things vary from AutoCAD because I'm unfamiliar with the API.  And as far as taking the process you're talking about, that doesn't work, unfortunately.  I'm trying to create a tool that will do all things in one for my users so they don't have to take all these steps to accomplish something.  I do have to create the Families for this because there is specific information I need to populate on these sheets based on specific shared parameters I've placed in Revit.  

 

I'm currently trying to figure out a way to place Families in a TitleBlock.  I've imported them to the TitleBlock Family, but it won't let me place them...  I think I might just have to create the whole TitleBlock by placing labels within it based on the parameters (just like the Families I've created) but without using the actual Families.

 

Any more ideas or insights are appreciated!!

0 Likes
Message 4 of 8

RPTHOMAS108
Mentor
Mentor

As far as I know the only type of family that can be added and placed within a title block family is an annotation symbol family. That would have to be shared to be available to the GetSubComponentIds function of the Titleblock element. I believe you can also find nested shared components by filtering.

0 Likes
Message 5 of 8

so-chong
Advocate
Advocate
Accepted solution

Hi,

I have a macro which may do the same thing your question is about creating AssemblyInstance.

I hope this will give you some guidance and good luck!

 

Cheers,

So-chong

 

 

using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Linq;

namespace RevitApiForum
{
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    [Autodesk.Revit.DB.Macros.AddInId("ED37A463-3779-4448-AB0E-2CBBA6D354A4")]
    public partial class ThisApplication
    {
        private void Module_Startup(object sender, EventArgs e)
        {

        }

        private void Module_Shutdown(object sender, EventArgs e)
        {

        }

        #region Revit Macros generated code
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(Module_Startup);
            this.Shutdown += new System.EventHandler(Module_Shutdown);
        }
        #endregion
      public void CreateAssemblyAndViewsAndSheet()
      {
        Document doc = this.ActiveUIDocument.Document;
        UIDocument uidoc = this.ActiveUIDocument;
        ICollection<ElementId> elementIds = uidoc.Selection.GetElementIds();    
        
        using (Transaction transaction = new Transaction(doc))
        {
          ElementId categoryId = doc.GetElement(elementIds.First()).Category.Id;
         
          if( AssemblyInstance.IsValidNamingCategory( doc, categoryId, uidoc.Selection.GetElementIds() ) )
          {

            transaction.Start("Create Assembly Instance");
            AssemblyInstance assemblyInstance = AssemblyInstance.Create( doc, uidoc.Selection.GetElementIds(), categoryId );
            transaction.Commit(); // need to commit the transaction to complete the creation of the assembly instance so it can be accessed in the code below
            
           if (transaction.GetStatus() == TransactionStatus.Committed)
           {
              transaction.Start("Set Assembly Name");
              assemblyInstance.AssemblyTypeName = "My Assembly Name";
              transaction.Commit();
           }
            
            if( assemblyInstance.AllowsAssemblyViewCreation() ) // check to see if views can be created for this assembly
            {

              if (transaction.GetStatus() == TransactionStatus.Committed)
              {

                transaction.Start("View Creation");                 
                ElementId titleBlockId = new FilteredElementCollector(doc)
                     .OfClass(typeof(FamilySymbol))
                     .OfCategory(BuiltInCategory.OST_TitleBlocks)
                     .Cast<FamilySymbol>()
                     .FirstOrDefault().Id;
                 
                  ViewSheet viewSheet = AssemblyViewUtils.CreateSheet( doc, assemblyInstance.Id, titleBlockId );
                  View3D view3d = AssemblyViewUtils.Create3DOrthographic( doc, assemblyInstance.Id );
                  ViewSection elevationTop = AssemblyViewUtils.CreateDetailSection( doc, assemblyInstance.Id, AssemblyDetailViewOrientation.ElevationTop );
                  ViewSection elevationLeft = AssemblyViewUtils.CreateDetailSection( doc, assemblyInstance.Id, AssemblyDetailViewOrientation.ElevationLeft );
                  ViewSection elevationRight = AssemblyViewUtils.CreateDetailSection( doc, assemblyInstance.Id, AssemblyDetailViewOrientation.ElevationRight );
                  ViewSection elevationFront = AssemblyViewUtils.CreateDetailSection( doc, assemblyInstance.Id, AssemblyDetailViewOrientation.ElevationFront );
                  ViewSection detailSectionA = AssemblyViewUtils.CreateDetailSection( doc, assemblyInstance.Id, AssemblyDetailViewOrientation.DetailSectionA );
                  ViewSection detailSectionB = AssemblyViewUtils.CreateDetailSection( doc, assemblyInstance.Id, AssemblyDetailViewOrientation.DetailSectionB );
                  ViewSection detailSectionH = AssemblyViewUtils.CreateDetailSection( doc, assemblyInstance.Id, AssemblyDetailViewOrientation.HorizontalDetail );
                  ViewSchedule materialTakeoff = AssemblyViewUtils.CreateMaterialTakeoff( doc, assemblyInstance.Id );
                  ViewSchedule partList = AssemblyViewUtils.CreatePartList( doc, assemblyInstance.Id );
             
                  Viewport.Create(doc, viewSheet.Id, view3d.Id, new XYZ ( 110 ) );
                  Viewport.Create(doc, viewSheet.Id, elevationTop.Id, new XYZ ( 220 ) );
                  Viewport.Create(doc, viewSheet.Id, elevationLeft.Id, new XYZ ( 11.70 ) );
                  Viewport.Create(doc, viewSheet.Id, elevationRight.Id, new XYZ ( 2.520 ) );
                  Viewport.Create(doc, viewSheet.Id, elevationFront.Id, new XYZ ( 210 ) );                  
                  Viewport.Create(doc, viewSheet.Id, detailSectionA.Id, new XYZ ( 1.51.250 ) );
                  Viewport.Create(doc, viewSheet.Id, detailSectionB.Id, new XYZ ( 0.51.50 ) );
                  Viewport.Create(doc, viewSheet.Id, detailSectionH.Id, new XYZ ( 1.520 ) );                  
                  ScheduleSheetInstance.Create(doc, viewSheet.Id, partList.Id, new XYZ ( 2.52.50 ) );
                  ScheduleSheetInstance.Create(doc, viewSheet.Id, materialTakeoff.Id, new XYZ ( 22.50 ) );                              
                transaction.Commit();
              }
            }
          }
        }
      }
    }
}

create_assembly_01.pngcreate_assembly_02.png

 

Message 6 of 8

Anonymous
Not applicable

Your FilteredElementCollector is what clued me to my mishap.  I was trying to load it with the Family as opposed to the FamilySymbol.  Now my TitleBlock sheet Family is loading - just not populating the parameter fields based on the AssemblyInstance elements.  I'm probably gonna have to do that manually, but it's not really a bother.  Thanks for the help!!!

0 Likes
Message 7 of 8

yafim.simanovsky
Participant
Participant

Hi,

Thank you for your post.

Here you create a materialtakeoff schedule and place it on a sheet in a specific location.

 

What if you just want to create it in the Schedules\Quantities dropdown?

 

Also, what if you want to control the fieldnames etc. that populate that schedule, is there a quick way to do that?

 

Thanks

0 Likes
Message 8 of 8

so-chong
Advocate
Advocate

Hi,

 

Thank you for your appreciation and welcome to the Revit API Forum.


I will recommend to explore the RevitApiDocs if you have questions like yours.


If you just want a schedule\quantity dropdown i believe there is a CreateSingleCategorySchedule() Method in the AssemblyViewUtils Class.


You can try this if it suit your needs.


If you like to control which fieldnames you want to show, there is a nice example in the ApiDocs how to do this.

AddRegularFieldToSchedule()

 

If you need more help, please start a new topic so more forum members got your attention and will help your if you have more questions.

0 Likes