- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How do I remove the unwanted dimensions after I shorten my piece on the drawing? When I shorten the part and holes go aways but the dimensions stay and turn magenta. How do I remove the dimensions. The code I have does not work. It works from my local files but not from vault.
This is the error I get when I open drawing from vault...
This is the code that I found that should but does not work...
This the view before....
This is after and want the dimensions removed before drawing is saved.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
What does the second tab of that error message say. The second tab of the error message sometimes contains more useful, and more detailed information about the error, and sometimes that will give us a clue as to where the error happened also. Did running that shown rule on that drawing cause the dimensions to turn magenta, or were the dimensions already magenta before trying to run that rule on that drawing? There is a way to find only the dimensions that are sick like that, and get rid of them. We can check the DrawingDimension.Attached property, which is a ReadOnly Boolean type value. They provide an example VBA macro code for removing dimensions that are not attached to anything also.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This is the second tab...
Running the rule did not make dimensions magenta. I shortened the part which is remove couple holes. This is what makes the dimensions turn magenta. I need the magenta dimensions to go away. How do I remove the magenta dimensions?
Thanks,
Jeff S.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
OK. That additional error data indicates that the error is happening when it tries to execute the DrawingDimension.Delete method. So, there must be at least one dimension that is giving this routine that problem. My guess is that it might be the first OrdinateDimension shown in the image. I just created a quick drawing view and added an OrdinateDimensionSet to the view, with multiple members. Then I created a quick, simple iLogic rule to loop through all generic DrawingDimensions on the sheet, and delete them. It threw the exact same error.
You could try this very similar iLogic rule, which includes a Try...Catch block to avoid the potential error, and let the rule continue.
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oDDims As DrawingDimensions = oDDoc.ActiveSheet.DrawingDimensions
For Each oDDim As DrawingDimension In oDDims
If oDDim.Attached = False Then
Try
oDDim.Delete
Catch
End Try
End If
Next 'oDDim
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS)
.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here is one more for pink dimensions
'This code deletes unattached dimensions ' Set a reference to the active drawing document Dim oDoc As DrawingDocument oDoc = ThisDoc.Document 'ThisServer.ActiveDocument ' Set a reference to the active sheet ' Dim oSheet As Sheet oSheet = oDoc.ActiveSheet ' Iterate over all dimensions in the drawing ' and delete unattached (sick) dimensions. For Each oDrawingDim In oSheet.DrawingDimensions If oDrawingDim.Attached = False Then Call oDrawingDim.Delete End If Next
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
At first I got these to work and now they are not working. I have the rule placed in the "After Open Document" in the event triggers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @jsternamanLULAE. Is it throwing an error when it does not work? If so, please include what the 'More Info' tab of the error message says. Do you believe it is possible that it is deleting some, but not all of the unattached dimensions? If that is the case, then we may need to either create a more detailed routine that checks what more specific derived type each dimension is, then react appropriately. Or we may need to put that whole loop and delete routine out into a separate Function type routine, so that it can be called multiple times in a loop, until it no longer makes any changes. One of the potential problems is that you are not allowed to delete the first dimension in a set. So if you have any OrdinateDimensionSets, then you can not delete just the first OrdinateDimension from each OrdinateDimensionSet. If you have any BaseLineDimensionSets, you can not delete the first dimension from each BaseLineDimensionSet, and so on. So, in those cases, if that first dimension in a set is not attached you may have to delete the whole set, instead of just the one dimension.
Edit: Another thing that comes to mind is that the views may have not had time to update before that code ran. What I mean is that views can be forced to update due to changes that happened in the model, and when those changes happen, that may cause some dimensions to no longer be attached. Well, if that updating of the views happens after the rule already ran, the rule would not have known about the dimensions not being attached. I am not sure if the 'after open' event is triggered, running that rule, before the views get updated or not. Just a thought. If you run that rule manually after that point in time, does it work on that drawing then?
Wesley Crihfield
(Not an Autodesk Employee)