Been a while since I asked a question here about sheet set objects, so I would like to ask a realy hard question.
The SheetSetObject has an inbuilt custom property called "TransmittalSetups", but the property has a different internal object structure compared to other CustomProperty
Dim myPropEnum As IAcSmEnumProperty = myCPB.GetPropertyEnumerator
Dim myPropName As String = Nothing
Dim myPropValue As AcSmCustomPropertyValue = Nothing
myPropName is a string, and in this instance it returns a value of "TransmittalSetups"
myPropValue.GetValue is a string, and it says "System.__ComObject" not a "value".
So my question is, how do identify this object, how to interigate it or assign it to its native object type.
I have tried to cast it to different IAcSmEnum types but without success.
we don't expose the COM API for the eTransmittal setup object. What do you need to do exactly?
I have a routine the "resets" the custom properties in the sheet, I delete the custom properties and I recreate it, I have noticed that this item is not being recreated, and when I "transmit" the sheets I get an internal error
here is the code I use:
Private Sub DeleteCustomProperties(ByRef myItem As IAcSmPersist, Optional ByVal Lock As Boolean = True) ''Throw New NotImplementedException Dim myDB As AcSmDatabase = myItem.GetDatabase Try Select Case myItem.GetTypeName Case "AcSmSheetSet" If True Then Dim mySheetset As AcSmSheetSet = myItem mySheetset.GetCustomPropertyBag.Clear() mySheetset.GetCustomPropertyBag.InitNew(myItem) End If Exit Select Case "AcSmSheet" If True Then Dim mySheet As AcSmSheet = myItem mySheet.GetCustomPropertyBag.Clear() mySheet.GetCustomPropertyBag.InitNew(myItem) End If Exit Select End Select Catch ex As Exception End Try End Sub
I then have routines that add back the custom properties that our office use (approx 140 ish custom properties)
This all works, but as statedt this "transmittalSetups" custom properties also gets deleted, It took a while to find this little sucker and am not too sure how to handle it.
Thanks if you have and help to offer.
Thanks for the information. I have not experianced this recreation of the "transmittalsetups", if not present. Do I need to delete the whole "custom property bag" and recreate it for it to be automaticaly recreated inside this contrainer.
My code (shown above) resets (clears) the "custom property bag" container, it does not delete it.
Is there a method to delete the custom property bag it, and recreate it? and more importantly if true, how?
Again thanks for any help you or others more proficient in this can offer.
I have tried clearing the custom properties of the sheetset but it does not seem to be removing the transmittal setup.
I have attached the dropbox link to the recording that shows the steps that I am following. Can you see if there is anything different from what you are trying ?
Here is the sample code that I am using to clear the custom properties
<CommandMethod("ClearCP")> _ Public Sub ClearCustomProps() Dim iterDb As IAcSmEnumDatabase Dim ItemDb As IAcSmPersist sheetSetMgr = New AcSmSheetSetMgr iterDb = sheetSetMgr.GetDatabaseEnumerator ItemDb = iterDb.Next sheetdb = ItemDb LockDatabase() Dim cBag1 As IAcSmCustomPropertyBag cBag1 = sheetdb.GetSheetSet().GetCustomPropertyBag cBag1.Clear() Dim Item1 As IAcSmPersist Dim iter1 As IAcSmEnumPersist iter1 = sheetdb.GetEnumerator Item1 = iter1.Next cBag1.InitNew(Item1) UnlockDatabase() End Sub
Thanks for taking the time to demonstrate and show example code. I will experiment with my code base to see if this solution also fits.
From what I can see, your assigning a veriable to the CPB, and processing that object directly, instead of the objects parent (if im explaining it properly???)
ie: my code needs to change to this:
Private Sub DeleteCustomProperties(ByRef myItem As IAcSmPersist, Optional ByVal Lock As Boolean = True) ''Throw New NotImplementedException Dim myDB As AcSmDatabase = myItem.GetDatabase Try Select Case myItem.GetTypeName Case "AcSmSheetSet" If True Then Dim mySheetset As AcSmSheetSet = myItem Dim myCPB As IAcSmCustomPropertyBag '' new myCPB = mySheetset.GetCustomPropertyBag '' new myCPB.Clear() '' new '' mySheetset.GetCustomPropertyBag.Clear() '' old '' mySheetset.GetCustomPropertyBag.InitNew(myItem) '' old myCPB.InitNew(myItem) '' new End If Exit Select Case "AcSmSheet" If True Then Dim mySheet As AcSmSheet = myItem Dim myCPB As IAcSmCustomPropertyBag '' new myCPB = mySheetset.GetCustomPropertyBag '' new myCPB.Clear() '' new '' mySheet.GetCustomPropertyBag.Clear() '' old ''mySheet.GetCustomPropertyBag.InitNew(myItem) '' old myCPB.InitNew(myItem) '' new End If Exit Select End Select Catch ex As Exception End Try End Sub
Im a bit busy doing engineering at the moment, but I should be able to test and confirm this this week. If you belive this will not work, please let me know.
Again, thanks for your help.
Not a problem.
Please feel free to test it when convenient.
I have attempted to incorporate your code example into my code (as shown above) but for some reason it is not working.
I have to iterate though all sheets, and clear the custom properties and recreate them (recreating the custom properties is being handled by another routine). I am passing the "myItem" object as an IAcSmPersist object (based on other code examples for iterating and analysing such objects), so the objects should work, but I cannot seem to work it out.
Your example works on the sheetset, but does not work on the sheets themselves, which shows that the CPB is being recreated, on the parent, but it is not processing the individual sheets.
Please if you can assist me I would really appreciate it.
Sorry, I still could not reproduce the problem.
Here is the sample code that I am using to clear the custom properties for a sheet and the dropbox link to the recording.
<CommandMethod("ClearSheetCP")> _ Public Sub ClearSheetCustomProps() Dim doc As Document doc = Application.DocumentManager.MdiActiveDocument Dim ed As Autodesk.AutoCAD.EditorInput.Editor ed = doc.Editor sheetSetMgr = New AcSmSheetSetMgr Dim iterDb As IAcSmEnumDatabase iterDb = sheetSetMgr.GetDatabaseEnumerator Dim ItemDb As IAcSmPersist ItemDb = iterDb.Next sheetdb = ItemDb LockDatabase() Dim sheetsetEnum As IAcSmEnumComponent sheetsetEnum = sheetdb.GetSheetSet().GetSheetEnumerator() Dim sheetsetItem As IAcSmComponent sheetsetItem = sheetsetEnum.Next() Dim iterator As IAcSmEnumPersist iterator = sheetdb.GetEnumerator() Dim item As IAcSmPersist item = iterator.Next() While item IsNot Nothing Dim type As String type = item.GetTypeName() Select Case type Case "AcSmSheet" Dim sheet As IAcSmSheet = TryCast(item, IAcSmSheet) Dim cBag1 As IAcSmCustomPropertyBag cBag1 = sheet.GetCustomPropertyBag cBag1.Clear() Dim Item1 As IAcSmPersist Dim iter1 As IAcSmEnumPersist iter1 = sheetdb.GetEnumerator Item1 = iter1.Next cBag1.InitNew(Item1) Case Else ed.WriteMessage("vbCrLfType :" + type) End Select item = iterator.Next() End While UnlockDatabase() End Sub
Can you please provide the steps and a buildable sample project to reproduce the issue ?
Please do not send any information that you consider confidential.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.