What is that you want to do with BlockView ?
Here is one snippet from one of my programs.
You may not be able to use it as is, but can understand how to use:
Dim oApp As SolidEdgeFramework.Application Dim oDoc As SolidEdgeDraft.DraftDocument Dim oSheet As SolidEdgeDraft.Sheet oApp = Marshal.GetActiveObject("SolidEdge.Application") oDoc = oApp.ActiveDocument oSheet = oDoc.ActiveSheet Dim oBOccs As SolidEdgeDraft.BlockOccurrences = oSheet.BlockOccurrences Dim oBOcc As SolidEdgeDraft.BlockOccurrence = oBOccs.Item(1) Dim oBlockView As SolidEdgeDraft.BlockView = oBOcc.BlockView oBlockView.BlockLabels.Add("Sample", "SampleValue", "Description", 0, 0, SolidEdgeDraft.BlockLabelOriginLocationConstants.igBlockLabelMiddleCenter, True, True, True, True, 0)
Similarly, you can add arcs, lines and several other 2D elements to the block view and they will appear in all occurrences of the block.
I need to create a "purge" function that will remove all blocks and blockviews not used.
A single block contain more than a view and only one or two views are used in the draft.
There are no problem with blocks, but for blockviews I'm not able to find a property that indicates me if a blockview is used by the draft.
My understanding is that you have Blocks and BlockOccurrences. The Block is the definition of a set of graphic entities, which can be changed in a BlockView. The usage of a Block is stored in all BlockOccurences, so you should look for that collection.
To purge your DraftDocumeng you have to remove all Blocks, which do NOT have BlockOccurrences.
You are right on Martin.
I tried to best replicate your issue by adding BlockView with few entities to some block occurrences.
Then I deleted all the block occurrences and run the purge loop as below.
I believe once the block is gone, the block views too are gone.
Why you need to delete them separately. My understanding about block views is still evolving as I have never used them before.
Dim oApp As SolidEdgeFramework.Application Dim oDoc As SolidEdgeDraft.DraftDocument oApp = Marshal.GetActiveObject("SolidEdge.Application") oDoc = oApp.ActiveDocument For Each oBlock As SolidEdgeDraft.Block In oDoc.Blocks If oBlock.OccurrenceCount = 0 Then oBlock.Delete() End If Next
If you mean to say the BlockViews linger out there after the block is gone, then perhaps you may want to nest another loop to first get rid of the blockviews before deleting the block.
For Each oBlock As SolidEdgeDraft.Block In oDoc.Blocks If oBlock.OccurrenceCount = 0 Then For Each oBlockView As BlockView In oBlock.Views oBlockView.Delete() Next oBlock.Delete() End If Next
Also, I don't know if there are BlockViews that are shared by more than one Block. and also if a BlockView needs to be deleted or purged only if it not used by any bock/blockoccurrence. Is that what you are looking for. In that case there is no direct property or method on the BlockView that indicates so. I think you need to loop through all BlockViews by Name and then crosscheck with all others Blocks if they have a BlockView with the same name and delete those BlockViews accordingly.
Thanks for the replies Martin and Tushar.
I confirm my issue is deleting views when they aren't used in a blockoccurrence.
I'll create a loop to search which views aren't in use.
Thanks a lot