AutoCAD Architecture Customization
Welcome to Autodesk’s AutoCAD Architecture Customization Forums. Share your knowledge, ask questions, and explore popular AutoCAD Architecture Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting classification for entities via .Net

1 REPLY 1
Reply
Message 1 of 2
THoffeller
577 Views, 1 Reply

Setting classification for entities via .Net

Hello,

 

I'm try to set a classification for a list of objects with .net. I'va found some discussions regarding changing and iterating classification trees, but none setting the classification for entites, similar to selecting a classification in ui.

 

Has anyone done this yet? Maybe I haven't found the discussion 😉

 

Thanks,

Tim

1 REPLY 1
Message 2 of 2
Keith.Brown
in reply to: THoffeller

This is how i set the "MvPart Type" classification for a MvPart in Autocad MEP.  It is a highly specialized method that only sets the "MvPart Type" for multi-view parts.  You could modify it to pass the style of the object you are setting the classification on as well as add the classification value as a parameter instead of hard coding it.  I am also using a global transaction which could be localized if you prefer.

 

 

 

        private static void SetMultiViewPartStyleClassification(MultiViewPartStyle multiViewPartStyle,
                                                                string multiViewPartClassification)
        {
            var dictionaryClassificationDefinition = new DictionaryClassificationDefinition(_database);
            ObjectId owningSystemId = dictionaryClassificationDefinition.GetAt("MvPart Type");
            var classificationDefinition =
                _transaction.GetObject(owningSystemId, OpenMode.ForRead) as ClassificationDefinition;

            if (classificationDefinition != null)
            {
                ClassificationTree classificationTree = classificationDefinition.ClassificationTree;
                if (classificationTree != null)
                {
                    ImpTreeCollection treeCollection = classificationTree.Children;
                    if (treeCollection != null)
                    {
                        int maximum = treeCollection.Count;
                        for (int i = 0; i < maximum; i++)
                        {
                            ObjectId classificationId = classificationTree.GetIdAt(i);
                            var classification =
                                _transaction.GetObject(classificationId, OpenMode.ForRead) as Classification;
                            if (classification != null)
                            {
                                if (classification.Name == multiViewPartClassification)
                                {
                                    ClassificationCollection classificationIds = multiViewPartStyle.Classifications;
                                    classificationIds.Add(classificationId);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }

 

Hope this helps. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost