Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to delete a vertical dimenision from a view?

2 REPLIES 2
Reply
Message 1 of 3
sohaib.as01
274 Views, 2 Replies

How to delete a vertical dimenision from a view?

Hello everyone. 
I was able to come up with a code that selects dimensions from a specific view and then we can do as we want with them.

In my case I want to:
- Go through all dimensions from a view

- Select vertical Dimensions
- Hide their dimension value

 

So far this code is only working for horizontal dimensions and not at all working for vertical dimensions. Can you guy please help me with that??

 

Edit 1: I just got to know that the line  

 

if oLinearDim.IntentOne.Geometry.Parent Is oView Then

 

is the cause of problem as the dimension is being taken from two different planes in an assembly and not from a single geometry. Can anyone tell me how do i fix it to ge all dimensions?

 

 

Sub Main
Dim oView As DrawingView = ActiveSheet.View("VIEW1").View
For Each oDim As DrawingDimension In GetDrawingDimForView(oView)
'If oDim.Type = kLinearGeneralDimensionObject Then
Dim oVertGenDim As LinearGeneralDimension = oDim
'If oVertGenDim.DimensionType = kVerticalDimensionType Then
oVertGenDim.HideValue = True

'oDim.Text = HEIGHT_RANGE
'End If
'End If
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
If oLinearDim.DimensionType = kHorizontalDimensionType Then
MessageBox.Show("Message", "Title")

oDrawDimsForView.Add(oDrawDimIterator)
End If


End If

Case Else

 

'Case is not handled...

 

End Select

 

Next

 

GetDrawingDimForView = oDrawDimsForView

 

End Function

Labels (2)
2 REPLIES 2
Message 2 of 3
petr.meduna
in reply to: sohaib.as01

I would try a different approach by checking lineardimension.IntentOne.PointOnSheet, if it lays within a view. See code below:

Sub Main
	Dim oView As DrawingView = ActiveSheet.View("main").View
	For Each oDim As GeneralDimension In oView.Parent.DrawingDimensions.GeneralDimensions
		'check dimension if it lays in view
		If IsDimensionInView(oDim, oView)
		
			'hide value
			oDim.HideValue = True
		End If
	Next
End Sub

Private Function IsDimensionInView(ByVal oDim As GeneralDimension, ByVal oView As DrawingView) As Boolean
	'create bounding box around a view
	Dim b As Box2d = ThisApplication.TransientGeometry.CreateBox2d()
	b.MinPoint = ThisApplication.TransientGeometry.CreatePoint2d(oView.Left, oView.Top - oView.Height)
	b.MaxPoint = ThisApplication.TransientGeometry.CreatePoint2d(oView.Left + oView.Width, oView.Top)
	
	Dim x As Double, xx As Double
	Select Case oDim.Type
		Case ObjectTypeEnum.kLinearGeneralDimensionObject
			Try
				'create linesegment2d representing dimension line and save startpoint and endpoint x values
				Dim lin As LineSegment2d = oDim.DimensionLine
				x = Round(lin.StartPoint.X, 5)
				xx = Round(lin.EndPoint.X, 5)
				
				'if bounding box contains intentone point a x's values are the same, it's a vertical dimension in view you are looking for
				If b.Contains(oDim.IntentOne.PointOnSheet) AndAlso x = xx Then
					Return True
				Else
					Return False
				End If
			Catch
				Return False
			End Try
	End Select
End Function
Message 3 of 3
WCrihfield
in reply to: sohaib.as01

Hi @sohaib.as01.  These cases which involve determining the connection between a DrawingDimension object and the DrawingView object that it is supposed to be associated with are always interesting.  As you likely noticed, there is no direct link between the two objects, so there have been many methods used over the years in the attempt to determine that connection.  I have seen folks try to go through the GeometryIntent object of the dimension, then follow the Geometry.Parent path to the DrawingView, but that does work 100% for all cases.  I have seen folks attempt to determine of some piece of geometry of the dimension is within the bounds of the view, similar to the example above.  And I have seen folks use suppression of views to determine which group of dimensions belong to specific views.  All of these methods will likely work a lot of the time, but I'm not sure if any of them will always work 100% of the time for all dimension types in all situations.  Below are a few links to some of the other forum posts trying to solve that same problem in these different ways.

https://adndevblog.typepad.com/manufacturing/2012/08/how-to-determine-which-drawing-dimensions-belon... 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/determine-scale-of-the-drawingdimens... 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/drawing-dimensions-from-specific-vie... 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/select-all-dimensions-in-one-view/m-... 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report