Hi,
I want delete all dimensions on a specific view. I using a rule that remove all dimensions on a sheet (as showed below), but I need remove only on a view. What is the change I need to make to the rule?
ActiveSheet = ThisDrawing.Sheet("A3:1")
Dim oSheet As Sheet = ThisDoc.Document.ActiveSheet
Dim oView As DrawingView = ActiveSheet.View("FRONTAL").View
Dim oDoc As Document =oView.ReferencedDocumentDescriptor.ReferencedDocument
'REMOVE DIMENSIONS
Dim oDim As DrawingDimension
For Each oDim In oSheet.DrawingDimensions
oDim.Delete
Next 'Dim
Solved! Go to Solution.
Solved by JhoelForshav. Go to Solution.
Solved by JhoelForshav. Go to Solution.
Maybe try using the pick command. There is a filter for drawing views.
ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, message)
Regards,
FINET L.
If this post solved your question, please kindly mark it as "Solution"
If this post helped out in any way to solve your question, please drop a "Like"I can´t use the pick command, because there aren´t designer interaction. Although I have tested this way and haven´t worked very well because occur the trouble below.
Below the updated code with pick command.
ActiveSheet = ThisDrawing.Sheet("AO:1")
Dim oSheet As Sheet = ThisDoc.Document.ActiveSheet
Dim oView As DrawingView = ActiveSheet.View("A").View
Dim oDoc As Document =oView.ReferencedDocumentDescriptor.ReferencedDocument
oDrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a drawing view.")
'REMOVE DIMENSIONS
Dim oDim As DrawingDimension
For Each oDim In oDrawingView.DrawingDimensions
oDim.Delete
Next 'Dim
Isn´t there a different command that work automatically?
It's a bit tricky to find the dimensions of a view because dimensions doesn't actually belong to a view, they belong to the sheet. So there's not way to find the dimensions through the view object...
I rewrote the function from here a bit to use for this:
See if it works for you 🙂
Sub Main Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Pick view") For Each oDim As GeneralDimension In GetDrawingDimForView(oView) oDim.Delete Next End Sub Function GetDrawingDimForView(oView As DrawingView) As ObjectCollection Dim oDrawDimsForView As ObjectCollection oDrawDimsForView = ThisApplication.TransientObjects.CreateObjectCollection Dim oDrawDims As DrawingDimensions oDrawDims = oView.Parent.DrawingDimensions Dim oDrawDimIterator As DrawingDimension For Each oDrawDimIterator In oDrawDims Select Case oDrawDimIterator.Type Case kLinearGeneralDimensionObject Dim oLinearDim As LinearGeneralDimension oLinearDim = oDrawDimIterator If oLinearDim.IntentOne.Geometry.Parent Is oView Then oDrawDimsForView.Add(oDrawDimIterator) End If Case kRadiusGeneralDimensionObject Dim oRadiusDim As RadiusGeneralDimension oRadiusDim = oDrawDimIterator If oRadiusDim.Intent.Geometry.Parent Is oView Then oDrawDimsForView.Add(oDrawDimIterator) End If Case kDiameterGeneralDimensionObject Dim oDiameterDim As DiameterGeneralDimension oDiameterDim = oDrawDimIterator If oDiameterDim.Intent.Geometry.Parent Is oView Then oDrawDimsForView.Add(oDrawDimIterator) End If Case kAngularGeneralDimensionObject Dim oAngularDim As AngularGeneralDimension oAngularDim = oDrawDimIterator If oAngularDim.IntentOne.Geometry.Parent Is oView Then oDrawDimsForView.Add(oDrawDimIterator) End If Case Else 'Case is not handled... End Select Next GetDrawingDimForView = oDrawDimsForView End Function
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Hi @JhoelForshav ,
Thank you for your help. This rule work very well, but it only deletedthe dimensions that were entered manually in drawing. The dimensions that were entered in a view by command (like showed bellow) have not been deleted.
'Example way to insert a dimension
Dim oDim1 As GeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(textPoint, oGeomIntent1, oGeomIntent2, DimensionTypeEnum.kVerticalDimensionType)
I tryed to change the "kLinearGeneralDimensionObject" for the "kGeneralDimensionObjetc" in one of the function's cases (like example below) but don't worked.
Case kGeneralDimensionObject
Dim oGeneralDim As GeneralDimension
oGeneralDim = oDrawDimIterator
If oGeneralDim.IntentOne.Geometry.Parent Is oView Then
oDrawDimsForView.Add(oDrawDimIterator)
End If
Can you help me update the rule to delete this dimension type?
Regards,
The dimension in your example is in fact an object of type kLinearGeneralDimension, so that's not the problem. The reason it doesn't work is because you have used an object as IntentOne that doesn't have the drawingview as it's parent property. What did you use as IntentOne here?
Anyways, I think maybe this approach will be better for you. I create a box around the view in question and delete every dimension that has its intentpoint inside that box. Try it and see how its better 🙂
Sub Main Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Pick view.") Dim oCol As ObjectCollection = GetDimsFromView(oView) For Each oDim As GeneralDimension In oCol oDim.Delete Next End Sub Function GetDimsFromView(oView As DrawingView) As ObjectCollection Dim oTG As TransientGeometry = ThisApplication.TransientGeometry Dim oBox As Box2d = oTG.CreateBox2d oBox.MaxPoint = oTG.CreatePoint2d(oView.Center.X + oView.Width / 2, oView.Top) oBox.MinPoint = oTG.CreatePoint2d(oView.Center.X - oView.Width / 2, oView.Top - oView.Height) oBox.Expand(0.001) Dim oDrawDimsForView As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection Dim oSheet As Sheet = oView.Parent For Each oDrawDimIterator As GeneralDimension In oSheet.DrawingDimensions.GeneralDimensions Select Case oDrawDimIterator.Type Case kLinearGeneralDimensionObject Dim oLinearDim As LinearGeneralDimension oLinearDim = oDrawDimIterator If oBox.Contains(oLinearDim.IntentOne.PointOnSheet) Then oDrawDimsForView.Add(oDrawDimIterator) Case kRadiusGeneralDimensionObject Dim oRadiusDim As RadiusGeneralDimension oRadiusDim = oDrawDimIterator If oBox.Contains(oRadiusDim.Intent.PointOnSheet) Then oDrawDimsForView.Add(oDrawDimIterator) Case kDiameterGeneralDimensionObject Dim oDiameterDim As DiameterGeneralDimension oDiameterDim = oDrawDimIterator If oBox.Contains(oDiameterDim.Intent.PointOnSheet) Then oDrawDimsForView.Add(oDrawDimIterator) Case kAngularGeneralDimensionObject Dim oAngularDim As AngularGeneralDimension oAngularDim = oDrawDimIterator If oBox.Contains(oAngularDim.IntentOne.PointOnSheet) Then oDrawDimsForView.Add(oDrawDimIterator) Case Else 'Case is not handled... End Select Next Return oDrawDimsForView End Function
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Hi @JhoelForshav ,
Ok, now I get it. The last solution worked perfectly. Thank you very much for your attention.
Regards
Can't find what you're looking for? Ask the community or share your knowledge.