Пример #1
0
        private void MRenderCtrl_Load(object sender, EventArgs e)
        {
            mDocument = new Document();
            mDbView   = mDocument.Initialize("3D");

            mRootSceneNode = new DocumentSceneNode(mDocument);
            mRenderCtrl.ShowSceneNode(mRootSceneNode);

            mContext = new UICommandContext(this);

            mDocument.EnableTransaction(false);
            var material = new MaterialElement();

            material.SetName("Default");
            mMaterialId = mDocument.AddElement(material);

            mDocument.EnableTransaction(true);

            mRenderCtrl.SetSelectCallback((PickedItem item) =>
            {
                var node      = item.GetNode();
                var elementId = node == null ? ElementId.InvalidId : new ElementId(node.GetUserId());
                mSelectionCallback(item, mDocument, elementId);
            });
        }
Пример #2
0
        public static PropertyValues UpdateMaterial(this MaterialElement mat, VaultAliases vaultAlias, int modelId)
        {
            var pvs = new PropertyValues();

            AddProperties(mat, pvs, vaultAlias, modelId);

            return(pvs);
        }
Пример #3
0
        public static ObjVer CreateMaterial(this MaterialElement mat, VaultAliases vaultAlias, int modelId, AccessControlList acl)
        {
            var objTypeId = vaultAlias.ObDict[OB.Material];
            var classId   = vaultAlias.CsDict[CS.Material];
            var pvs       = new PropertyValues();

            AddProperties(mat, pvs, vaultAlias, modelId);
            return(BaseElementExtensions.CreateBasicObject(objTypeId, classId, pvs, vaultAlias.Vault, acl));
        }
Пример #4
0
        public static void AddProperties(this MaterialElement mat, PropertyValues pvs, VaultAliases vaultAlias, int modelId)
        {
            mat.AddBasicProperties(pvs, vaultAlias, modelId);

            if (mat.Parameters.Count > 0)
            {
                var pPV = BaseElementExtensions.CreateParameterProp(mat.Parameters, vaultAlias);
                pvs.Add(-1, pPV);
            }
        }
Пример #5
0
        private static MaterialElement GetMat(Document doc, Material m)
        {
            var mm = new MaterialElement
            {
                Id   = m.Id.IntegerValue,
                Name = m.Name,
                Guid = m.UniqueId
            };
            var pIter = m.Parameters.ForwardIterator();

            while (pIter.MoveNext())
            {
                var p = (Parameter)pIter.Current;
                mm.Parameters.Add(p.GetParameter(doc));
            }
            return(mm);
        }