.NET

Reply
Contributor
BIM_Manager_Orbicon
Posts: 22
Registered: ‎10-27-2010
Message 1 of 7 (257 Views)

How to rename an existing classification object

257 Views, 6 Replies
07-30-2012 05:00 AM

My task is to write an automated routine that checks for a certain classification added to Duct objects.

In the classification definition SfB all classification names of the form (XX)X should be altered/renamed to the form XX.X

 

Defining a Classification object Classfc as Autodesk.Aec.DatabaseServices.Classification my problem is that the property Classfc.Name is readonly

I struggled with finding another way to solve the problem but have not been able to find a solution.

 

Any ideas?

 

Jan Grenov
CAD Manager
Orbicon A/S
ADN Support Specialist
mikako.harada
Posts: 52
Registered: ‎08-26-2007
Message 2 of 7 (219 Views)

Re: How to rename an existing classification object

08-02-2012 08:43 AM in reply to: BIM_Manager_Orbicon

Hi Jan,

 

How about Rename() method of DictionaryClassificationDefinition class?  Dictionary is a container class of dictionary record.  If you haven't looked at it, could you try? 


Mikako Harada
Developer Technical Services
Autodesk Developer Network

Contributor
BIM_Manager_Orbicon
Posts: 22
Registered: ‎10-27-2010
Message 3 of 7 (199 Views)

Re: How to rename an existing classification object

08-02-2012 11:13 PM in reply to: BIM_Manager_Orbicon

Thanks t for the hint. I will give it a try and let you know how it went.

Jan Grenov
CAD Manager
Orbicon A/S
Contributor
BIM_Manager_Orbicon
Posts: 22
Registered: ‎10-27-2010
Message 4 of 7 (167 Views)

Re: How to rename an existing classification object

08-06-2012 09:00 AM in reply to: mikako.harada

Hi Mikako

 

That got me some of the way. Now I can rename the classification definition using the code below. Now I just need to rename som nodes inside the classification tree. However I am having troubles using the classificationtree-rename method. (Have a look at the RenameClassification below).

 

Any sugestions?

 

Code example:

 

<Autodesk.AutoCAD.Runtime.

CommandMethod("RenameClassificationDef")> _

   

PublicSub RenameClassificationDef()

       

Dim ed AsEditor = Application.DocumentManager.MdiActiveDocument.Editor

       

Dim db AsDatabase = HostApplicationServices.WorkingDatabase

       

Dim dictClsfcDef AsDictionaryClassificationDefinition = NewDictionaryClassificationDefinition(db)

       

Dim id AsObjectId = dictClsfcDef.GetAt("AAU_SfBClassification")

       

Try

           

Using tr AsTransaction = db.TransactionManager.StartTransaction

               

Dim SfBClsfc AsObjectId

               

Dim AAUClsfc AsObjectId

               

Try

                    SfBClsfc = dictClsfcDef.GetAt(

"SfB")

               

Catch

               

EndTry

               

Try

                    AAUClsfc = dictClsfcDef.GetAt(

"AAU_SfBClassification")

               

Catch

               

EndTry

               

If AAUClsfc.IsNull AndAlsoNot SfBClsfc.IsNull Then

                    dictClsfcDef.Rename(

"SfB", "AAU_SfBClassification", tr)

               

EndIf

               

Dim Recs AsObjectIdCollection = dictClsfcDef.Records

               

ForEach RecID AsObjectIdIn Recs

                   

Dim RecObj AsClassificationDefinition = RecID.GetObject(OpenMode.ForWrite)

                   

Dim VVSID AsObjectId = RecObj.GetClassification("VVS-anlæg")

                   

Dim VVSObj AsClassification = VVSID.GetObject(OpenMode.ForWrite)

               

Next

                tr.Commit()

           

EndUsing

       

Catch ex AsException

            ed.WriteMessage(

"Error : " + ex.ToString + vbCrLf)

       

EndTry

   

EndSub

 

 

Here is the RenameClassification-sub (that fails):

 

Public Sub RenameClassification(ByRef tr AsTransaction, ByRef node AsClassificationTree)

       

Dim ed AsEditor = Application.DocumentManager.MdiActiveDocument.Editor

       

If node IsNothingThen

           

Return

       

EndIf

       

IfNot (node.Id.IsNull) Then

           

Dim classi AsClassification = CType(tr.GetObject(node.Id, OpenMode.ForRead), Classification)

            node.Rename(classi.ObjectId,"SomeNewName") THIS FAILS!

       

EndIf

       

If node.Children.Count > 0 Then

           

ForEach ChildTree In node.Children

                RenameClassification(tr, ChildTree)

           

Next

       

EndIf

   

EndSub

Jan Grenov
CAD Manager
Orbicon A/S
ADN Support Specialist
mikako.harada
Posts: 52
Registered: ‎08-26-2007
Message 5 of 7 (149 Views)

Re: How to rename an existing classification object

08-06-2012 03:44 PM in reply to: BIM_Manager_Orbicon

Hi Jan,

 

Could you post this question to AutoCAD Architecture customization forum? 

 

http://forums.autodesk.com/t5/AutoCAD-Architecture/bd-p/54

 

Sounds like your question became AutoCAD Architecture specific. The audience of this forum is probably wondering what we are talking about :-)  It will be more appropriate to post in AutoCAD Architecture one.  

 

Glad to hear you have solved the initial question of renaming the classification definition.

  

Thank you for cooperation. 

 


Mikako Harada
Developer Technical Services
Autodesk Developer Network

Contributor
BIM_Manager_Orbicon
Posts: 22
Registered: ‎10-27-2010
Message 6 of 7 (131 Views)

Re: How to rename an existing classification object

08-07-2012 12:29 AM in reply to: BIM_Manager_Orbicon

I will do that.
Thanks so far :-)

Jan Grenov
CAD Manager
Orbicon A/S
Contributor
BIM_Manager_Orbicon
Posts: 22
Registered: ‎10-27-2010
Message 7 of 7 (125 Views)

Re: How to rename an existing classification object

08-07-2012 01:13 AM in reply to: mikako.harada

 

Posted question in the Architecture customization forum as "How to make the rename-method of the Classificationtree work?"

Jan Grenov
CAD Manager
Orbicon A/S
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.