Cannot save drawing with user defined property sets in autocad MEP

Cannot save drawing with user defined property sets in autocad MEP

Anonymous
Not applicable
637 Views
1 Reply
Message 1 of 2

Cannot save drawing with user defined property sets in autocad MEP

Anonymous
Not applicable

Hi,

 

I am adding blockreferences to a drawing from Excel with a plugin i created. I attach a self-defined property set called "Elektroteknikk" to the references but when i try to save the drawing i get the following error:

 

"One or more objects in this drawing cannot be saved to the specified format. The operation was not completed and no file was created"

 

Capture.PNGCapture.PNG

 

 

I am using the standard aecpropdatamdg dll.

 

 

But when i manually attach the propertysetdefinition to the blockreferences in autocad i am able to save the drawing.

 

This is the code i am using to attach the propertysetdef and values to the blockrefrence

 

if (PropDefValues != null)
            {
                var propSetDef = (PropertySetDefinition)PropDefValues[-1];
                using (Transaction tr2 = db.TransactionManager.StartOpenCloseTransaction())
                {
                    PropertyDataServices.AddPropertySet(br, propSetDef.Id);
                    
                    tr2.Commit();
                }
                var propSetId = PropertyDataServices.GetPropertySet(br, propSetDef.Id);

                using (var propSet = (PropertySet)tr.GetObject(propSetId, OpenMode.ForWrite, false))
                {
                    foreach(var KVPair in PropDefValues)
                    {
                        if(KVPair.Key != -1)
                            propSet.SetAt(KVPair.Key, KVPair.Value);
                    }
                }
            }

ANY help??

0 Likes
Accepted solutions (1)
638 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

I managed to solve it. I forgot to convert DBNull values to null at one point in my code.

0 Likes