AutoCAD Architecture PropertySetDefinition using .net

AutoCAD Architecture PropertySetDefinition using .net

cesar_mayorine362SG
Contributor Contributor
1,189 Views
3 Replies
Message 1 of 4

AutoCAD Architecture PropertySetDefinition using .net

cesar_mayorine362SG
Contributor
Contributor

I am looking for a way to export from a source drawing to another.

The PropertySetDefinition, in drawing 1 contains an updated PropertySetDefinition and this should be overwritten in the receiving drawing.

 

I try:

 

sourceDb.WblockCloneObjects(sourceIds, destDbMsId, mapping, DuplicateRecordCloning.Replace, false)

 

but 

DuplicateRecordCloning.Replace dont work.

 

 

0 Likes
1,190 Views
3 Replies
Replies (3)
Message 3 of 4

cesar_mayorine362SG
Contributor
Contributor

 

Hello everyone,

 

I have tried these codes, the problem is that they do not overwrite the User Extended  Parameters from AEC Space.
If I use WblockCloneObjects, it generates a copy of the Spaces Parameters with "(2)" it comes from the Source drawing,  but it does not overwrite the current one.

 

Best regards

 

César Mayorine.

0 Likes
Message 4 of 4

Gepaha
Collaborator
Collaborator

I assume you are trying to import a Space Style! But, the idea is the same for importing PropertySetDefiniton.

What do you mean by User Extended Parameters from AEC Space?

I did a very simple test and it's working correctly with CloningHelper.
Are you using CloningHelper MergeType = DictionaryRecordMergeBehavior.Overwrite?

 

 

 

[CommandMethod("ImportSpaceStyleTest")]
 public void ImportSpaceStyleTest()
 {
   try
   {
      Database dbDestination =  HostApplicationServices.WorkingDatabase;                
      string SourcePath = @"C:\temp\Spaces - Residential (Metric).dwg";
      Database dbSource = new Database(false, true);
      dbSource.ReadDwgFile(SourcePath,  System.IO.FileShare.Read, true, "");                
      DictionarySpaceStyle dictSpaceStyle = new DictionarySpaceStyle(dbSource);

      //  get the list of style ids that you want to import.
      //  (1) if you want to import everything, use this:
      // the list of ids in the style dictionary.
      // ObjectIdCollection objCollectionsrc=dictStyle.Records;
      // (2) if you want to import a specific style, use this:               
      // we assume you know the name of style you want to import. 

      AcDb.ObjectIdCollection objCollectionsrc=new AcDb.ObjectIdCollection();
      objCollectionSrc.Add(dictSpaceStyle.GetAt("Bathroom_Large"));

      //  now use CloningHelper class to import styles.  
      //  there are four options for merge type:
      //    Normal     = 0, // no overwrite
      //    Overwrite  = 1, // this is default.
      //    Unique     = 2, // rename it if the same name exists.
      //    Merge      = 3  // no overwrite + add overlapping as anonymous

      Autodesk.Aec.ApplicationServices.Utility.CloningHelper helpme = new Autodesk.Aec.ApplicationServices.Utility.CloningHelper();

      // helpme.MergeType = Autodesk.Aec.ApplicationServices.Utility.DictionaryRecordMergeBehavior.Normal;
      helpme.MergeType = Autodesk.Aec.ApplicationServices.Utility.DictionaryRecordMergeBehavior.Overwrite;
      // helpme.MergeType = Autodesk.Aec.ApplicationServices.Utility.DictionaryRecordMergeBehavior.Unique;
      // helpme.MergeType = Autodesk.Aec.ApplicationServices.Utility.DictionaryRecordMergeBehavior.Merge;        

      helpme.Clone(dbSource, dbDestination, objCollectionSrc, dictSpaceStyle.RecordType, true);
   }
   catch (System.Exception e)
   { Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(e.Message);                
   }
}

 

 

 

 

 

[CommandMethod("ImportPropertySetDefinitionTest")]
public void ImportPropertySetDefinitionTest()
{
  try
  {
     Database dbDestination = HostApplicationServices.WorkingDatabase;
     string SourcePath = @"C:\temp\Schedule Tables (Metric).dwg";
     Database dbSource = new Database(false, true);
     dbSource.ReadDwgFile(SourcePath, System.IO.FileShare.Read, true, "");
     DictionaryPropertySetDefinitions dictPropSetDef = new DictionaryPropertySetDefinitions(dbSource);

     AcDb.ObjectIdCollection objCollectionsrc=new AcDb.ObjectIdCollection();
     objCollectionSrc.Add(dictPropSetDef.GetAt("SpaceStyles"));

     Autodesk.Aec.ApplicationServices.Utility.CloningHelper helpme = new Autodesk.Aec.ApplicationServices.Utility.CloningHelper();
     helpme.MergeType = Autodesk.Aec.ApplicationServices.Utility.DictionaryRecordMergeBehavior.Overwrite;
     helpme.Clone(dbSource, dbDestination, objCollectionSrc, dictPropSetDef.RecordType, true);
  }
  catch (System.Exception e)
  {
     Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(e.Message);
  }
}

 

 

 

0 Likes