Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Hide un attached dimensions

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
2032 Views, 5 Replies

Hide un attached dimensions

Hi all,

 

I have created master assembly and drawing, using ilogic rules I am creating one more copy of these files(using SaveCopyAs command). In the newly created assembly some of the parts will be suppressed, the dimensions given to these suppressed parts showing as un attached, I need to hide/delete these dimensions.

 

I have written following rule. What I am doing is moving the un attached dimensions to new layer (dummy) and switch off this layer. When I run this rule, it is giving error. Any help will be greatly appreciated

doc = ThisDoc.Document
Dim oHideLayer
oHideLayer = doc.StylesManager.Layers.Item("Dimension (ANSI))").Copy("dummy")

'iterate each dimension
Dim oEachDim As DrawingDimension
For Each oEachDim In doc.ActiveSheet.DrawingDimensions
'If it Is orphaned
If Not oEachDim.Attached Then
' set the layer to the dummy layer
oEachDim.Layer = oHideLayer
EndIf
Next

'hide this layer
oHideLayer.Visible = False
doc.Update

  

 

 

5 REPLIES 5
Message 2 of 6
mrattray
in reply to: Anonymous

Welcome to the forums.

What is the error that you get when you run the rule?
Have you been able to narrow it down to a specific line of code?

Also, for future inquiries, the Inventor Customization forum has lots of information about programming in it, as well as plenty of users experienced in automating Inventor.
Mike (not Matt) Rattray

Message 3 of 6
Curtis_Waguespack
in reply to: Anonymous

Hi rudresh_middleby,

 

I agree with mrattray's thought that the Inventor Customization Forum would be a better place for this type of question, but here is an ilogic rule that follows pretty close to what you had:

 

oHideOption = InputRadioBox("Select an option:", _
"Hide Orphan Dimensions", "Show Orphan Dimensions", True, "iLogic")
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")  
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
	End If
	Next
	'hide the layer 
	oOrphanLayer.Visible = False
Else
	'show the layer 
	oOrphanLayer.Visible = True
	End If
oDoc.Update 

 

Also here is a rule to delete the unattached dimensions, just in case it helps:

 

 

oDoc = ThisDoc.Document
'Loop through and delete all unattached dimensions
For Each oDrawingDim In oDoc.ActiveSheet.DrawingDimensions
If oDrawingDim.Attached = False Then
'delete unattached dims
oDrawingDim.Delete
End If
Next

 I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 4 of 6
Anonymous
in reply to: Curtis_Waguespack

Hi Curtis, Thanks for the feedback.

 

Your second suggestion worked really well. Thanks a lot

Message 5 of 6

Hi everyone,

 

I was asked about Orphan Centerlines on another thread, so I thought I would add this information here in order to keep things tied together. So here is a quick example that deletes un-attached (orphaned) dimensions, centermarks, and centerlines.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

oDoc = ThisDoc.Document

'Delete all orphaned dimensions
For Each oDrawingDim In oDoc.ActiveSheet.DrawingDimensions
	If oDrawingDim.Attached = False Then
	oDrawingDim.Delete
	End If
Next

'Delete all orphaned centermarks
For Each oCenterMark In oDoc.ActiveSheet.Centermarks
	If oCenterMark.Attached = False Then
	oCenterMark.Delete
	End If
Next

'Delete all orphaned centerlines
For Each oCenterLine In oDoc.ActiveSheet.Centerlines 
	If oCenterLine.Attached = False Then
	oCenterLine.Delete
	End If
Next

 

Message 6 of 6

I need your help your rule is working for me but only if annotations are unattached intentionally by me if I make a replace model reference some annotations will loose track in that case I'm not being able to delete them.

The only way it's working is if I move them a little then they start to assume they are actually lost.

 

Attached is my file.

 

I tried this change but it didn't work, could you rewrite the ilogic for me please?

 

If oCenterMark.Attached <> True

 

Manuel Campos Costa

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

Post to forums  

Autodesk Design & Make Report