Dimension Visibility

Dimension Visibility

layochim
Enthusiast Enthusiast
124 Views
2 Replies
Message 1 of 3

Dimension Visibility

layochim
Enthusiast
Enthusiast

Hello,  I'm trying to hide dimensions on my drawing.  I found a rule that worked the first go around but now it's throwing an error.  I'm suppressing a feature and then turning the feature back on for certain conditions.

Is there a better alternative to turning dimensions off or is the code getting confused as i am?

 

If Parameter("STRAIGHT CONVEYOR.iam.Legs") = "No" Then
oHideOption = True
		oDoc = ThisDoc.Document

		Try
			'try to create the layer
			oOrphanLayer = oDoc.StylesManager.Layers.Item(1).Copy("Orphan Dims")
		Catch
			'assume error means layer already exists and
			'assign layer to variable
			oOrphanLayer = oDoc.StylesManager.Layers.Item("Orphan Dims")
			oLayer = oDoc.StylesManager.Layers.Item("Dimension(ISO)")
		End Try

		If oHideOption = True Then
			'Loop through all dimensions
			Dim oDrawingDim As DrawingDimension
			For Each oDrawingDim In oDoc.ActiveSheet.DrawingDimensions
				'look at only unattached dims
				If oDrawingDim.Attached = False Then
					' set the layer to the dummy layer 
					oDrawingDim.Layer = oOrphanLayer
				Else
					oDrawingDim.Layer = oLayer 
				End If
			Next
			'hide the layer 
			oOrphanLayer.Visible = False
		Else
			'show the layer 
			oOrphanLayer.Visible = True
		End If
		oDoc.Update
	End If

layochim_0-1754595986860.png

 

 

0 Likes
Accepted solutions (1)
125 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Hi @layochim.  The error message is pointing to Line 12 as the source of the error.  When I look at your example code and counted down what looked like 12 rows, that is the following line of code:

oLayer = oDoc.StylesManager.Layers.Item("Dimension(ISO)")

If that is correct, then I suspect it is not able to find that Layer.  I use the ANSI standard, and the similarly named Layer in that standard appears to have a 'space' between the word "Dimension" and the "(ANSI)", like this "Dimension (ANSI)", so maybe that is the current issue.

However, if your intention is to leave orphaned drawing dimensions in place, after you eliminate the model feature that they were attached to, then later turn the feature back on, then reattach those orphaned dimensions...good luck with that.  I don't do much drawing dimensioning by code myself, but I think I know enough about it that it would be pretty difficult to manage successfully.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

layochim
Enthusiast
Enthusiast

@WCrihfield sounds like a tough biscuit.  The Auto Dimensioning is for an outside program that i'm using.  I'll talk with that programmer and see what they recommend as well.  The ISO part i didn't catch, thanks for pointing that out to me.

0 Likes