.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How to rename an existing classifica tion object
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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?
CAD Manager
Orbicon A/S
Re: How to rename an existing classifica tion object
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
Re: How to rename an existing classifica tion object
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks t for the hint. I will give it a try and let you know how it went.
CAD Manager
Orbicon A/S
Re: How to rename an existing classifica tion object
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
CAD Manager
Orbicon A/S
Re: How to rename an existing classifica tion object
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Jan,
Could you post this question to AutoCAD Architecture customization forum?
http://forums.autodesk.com/t5/AutoCAD-Architecture
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
Re: How to rename an existing classifica tion object
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I will do that.
Thanks so far :-)
CAD Manager
Orbicon A/S
Re: How to rename an existing classifica tion object
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Posted question in the Architecture customization forum as "How to make the rename-method of the Classificationtree work?"
CAD Manager
Orbicon A/S

