DynamicModelUpdate.SectionUpdater.UpdateInitialParameters C# (CSharp) Method

UpdateInitialParameters() private method

private UpdateInitialParameters ( Document doc ) : void
doc Document
return void
        internal void UpdateInitialParameters(Document doc)
        {
            Transaction t = new Transaction(doc, "Update parameters");
               t.Start();

               SchemaBuilder builder = new SchemaBuilder(m_schemaId); //(new Guid("{4DE4BE80-0857-4785-A7DF-8A8918851CB2}"));
               builder.AddSimpleField("Position", typeof(XYZ)).SetUnitType(UnitType.UT_Length);
               builder.AddSimpleField("Orientation", typeof(XYZ)).SetUnitType(UnitType.UT_Length);
               builder.SetSchemaName("WallPositionData");
               builder.SetDocumentation("Two points in a Window element that assist in placing a section view.");
               builder.SetVendorId("adsk");
               builder.SetApplicationGUID(doc.Application.ActiveAddInId.GetGUID());

               m_schema = builder.Finish();

               t.Commit();

               t.Start();
               Field fieldPosition = m_schema.GetField("Position");
               Field fieldOrientation = m_schema.GetField("Orientation");

               FamilyInstance window = doc.get_Element(m_windowId) as FamilyInstance;

               Entity storageEntity = new Entity(m_schema);

               LocationPoint lp = window.Location as LocationPoint;
               XYZ location = lp.Point;

               storageEntity.Set<XYZ>(fieldPosition, location, DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES);

               XYZ orientation = window.FacingOrientation;
               storageEntity.Set<XYZ>(fieldOrientation, orientation, DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES);
               window.SetEntity(storageEntity);

               t.Commit();
        }

Usage Example

Example #1
0
        private void RegisterSectionUpdaterOnOpen(object source, DocumentOpenedEventArgs args)
        {
            if (args.Document.Title.StartsWith("AssociativeSection"))
            {
                m_sectionUpdater = new SectionUpdater(m_thisAppId);
                m_sectionUpdater.Register(args.Document);

                bool enableSecondUpdate = false;
                if (enableSecondUpdate)
                {
                    m_sectionUpdater.UpdateInitialParameters(args.Document);
                }
            }

            args.Document.DocumentClosing += UnregisterSectionUpdaterOnClose;
        }
All Usage Examples Of DynamicModelUpdate.SectionUpdater::UpdateInitialParameters