示例#1
0
        public static void ProprieteUtilisateur(String prop, String valeur)
        {
            PdmObjectId oidProp = Ts.Pdm.SearchDocumentByName(PdmObjectId.Empty, prop)[0];

            if (oidProp.IsEmpty)
            {
                return;
            }

            DocumentId didProp = Ts.Documents.GetDocument(oidProp);

            if (didProp.IsEmpty)
            {
                return;
            }

            ElementId eidParam = Ts.Parameters.SearchUserPropertyParameter(docId, didProp);

            if (eidParam.IsEmpty)
            {
                eidParam = Ts.Parameters.CreateUserPropertyParameter(docId, didProp);
            }

            if (eidParam.IsEmpty)
            {
                return;
            }

            Ts.Parameters.SetTextValue(eidParam, valeur);
        }
示例#2
0
        private void AddToColl(PdmObjectId id, ItemCollection items)
        {
            List <PdmObjectId> folderList, documentList;

            TopSolidHost.Pdm.GetConstituents(id, out folderList, out documentList);
            foreach (PdmObjectId did in documentList)
            {
                items.Add(new PdmItem(did));
            }
            foreach (PdmObjectId fid in folderList)
            {
                AddToColl(fid, items);
            }
        }
示例#3
0
 public PdmItem(PdmObjectId _id)
 {
     Id   = _id;
     Name = TopSolidHost.Pdm.GetName(_id);
 }
示例#4
0
        private static void MajPropriete(String oldDomain, String oldName, String nvDomain, String nvName, String valeur = "")
        {
            Log.Message("MajPropriete");

            PdmObjectId idOld = TopSolidHost.Pdm.SearchDocumentByName(PdmObjectId.Empty, oldName)[0];

            if (idOld.IsEmpty)
            {
                return;
            }
            Log.Message("   idOld -> Ok");

            PdmObjectId idNv = TopSolidHost.Pdm.SearchDocumentByName(PdmObjectId.Empty, nvName)[0];

            if (idNv.IsEmpty)
            {
                return;
            }
            Log.Message("   idNv -> Ok");


            if (!TopSolidHost.Application.StartModification("My Action", false))
            {
                return;
            }

            try
            {
                Log.Message("Modification");

                TopSolidHost.Documents.EnsureIsDirty(ref docId);

                DocumentId idOldDoc = TopSolidHost.Documents.GetDocument(idOld);
                if (!idOldDoc.IsEmpty)
                {
                    Log.Message("       idOldDoc -> Ok");

                    ElementId idOldParam = TopSolidHost.Parameters.SearchUserPropertyParameter(docId, idOldDoc);
                    if (!idOldParam.IsEmpty)
                    {
                        Log.Message("       idOldParam -> Ok");

                        DocumentId idNvDoc = TopSolidHost.Documents.GetDocument(idNv);
                        if (!idNvDoc.IsEmpty)
                        {
                            Log.Message("       idNvDoc -> Ok");

                            ElementId idNvParam = TopSolidHost.Parameters.SearchUserPropertyParameter(docId, idNvDoc);
                            if (idNvParam.IsEmpty)
                            {
                                idNvParam = TopSolidHost.Parameters.CreateUserPropertyParameter(docId, idNvDoc);
                            }

                            if (idNvParam.IsEmpty)
                            {
                                Log.Message("       idNvParam -> Ok");

                                if (String.IsNullOrWhiteSpace(valeur))
                                {
                                    valeur = TopSolidHost.Parameters.GetTextValue(idOldParam);
                                    TopSolidHost.Parameters.SetTextValue(idNvParam, valeur);
                                }
                            }
                        }
                    }
                }

                TopSolidHost.Application.EndModification(true, true);
            }
            catch
            {
                Log.Message("Erreur");
                TopSolidHost.Application.EndModification(false, false);
            }
        }