Ordinate Dimensions - delete by rule ??

Ordinate Dimensions - delete by rule ??

ralfmja
Advocate Advocate
729 Views
6 Replies
Message 1 of 7

Ordinate Dimensions - delete by rule ??

ralfmja
Advocate
Advocate

Hello,

 

I prepare code to delete all drawing dimension. But I have a problem with ordinate dimension.

obraz.png

When I have drawing with this kind of dimension my rule have error like on gif.

 

If I delete ordinate dimension manually (del key) everthing is ok.

 

Can you help me what is wrong ??

 

My code:

 

 

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet

'delete sheet formats

Dim oCurrentNumber As Sheet
oCurrentNumber = oDoc.ActiveSheet

' Iterate through the sheets, and delete the title blocks and symbols

For Each oSheet In oDoc.Sheets
    oSheet.Activate
    
    Try
    oSheet.TitleBlock.Delete
    Catch
    'catch error if no border found
    End Try
    
    Try
    oSheet.Border.Delete
    Catch
    'catch error if no border found
    End Try
    
Next

'set back to original sheet
oCurrentNumber.Activate

'CLEAR DRAWING
Dim oCL As Centerline
Dim oCM As Centermark
Dim oBalloon As Balloon
Dim oThreadNote As HoleThreadNote
Dim oOrdDim As OrdinateDimension
Dim oDrawingDim As DrawingDimension

	For Each oSheet In oDoc.Sheets
	oSheet.Activate

		For Each oCL In oSheet.Centerlines
			'If oCL.Attached = False
				oCL.Delete
			'End if 'Centerline attached
		Next 'Centerline
		
		For Each oCM In oSheet.Centermarks
			'If oCL.Attached = False
				oCM.Delete
			'End if 'Centermarks attached
		Next 'Centermarks
		
		For Each oBalloon In oSheet.Balloons
			'If oBalloon.Attached = True
				oBalloon.Delete
			'End If 'Baloon attached
		Next 'Balloon
		
		For Each oThreadNote In oSheet.DrawingNotes.HoleThreadNotes
			'If oBalloon.Attached = False
				oThreadNote.Delete
			'End If 'Baloon attached
		Next 'Balloon
		
		For Each oSymbol In oSheet.SketchedSymbols
		'look for the symbol by name
		'If oSymbol.Name = "UWAGA: 1" Then
			oSymbol.Delete
		'End If
		Next 
		
		For Each oOrdDim  In oSheet.DrawingDimensions.OrdinateDimensions
			'If oOrdDim.Attached = False
				oOrdDim.Delete
			'End If 'Baloon attached
		Next 
		
		For Each oDrawingDim In oSheet.DrawingDimensions
	        'If oDrawingDim.Attached = False Then
	            Call oDrawingDim.Delete
	        'End If
	    Next
		
	Next
	

I try delete this dimension by :

 

For Each oOrdDim  In oSheet.DrawingDimensions.OrdinateDimensions
			'If oOrdDim.Attached = False
				oOrdDim.Delete
			'End If 'Baloon attached
		Next 

unfortunetly something go wrong.

 

 

Someone help me ??

 

Thanks in advance

ralfmj

 

0 Likes
Accepted solutions (1)
730 Views
6 Replies
Replies (6)
Message 2 of 7

JelteDeJong
Mentor
Mentor

if i test your code it works fine for me. can u share an example drawing?

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 7

ralfmja
Advocate
Advocate

Ofcourse

 

In attachment

 

Regards,

ralfmj

0 Likes
Message 4 of 7

JelteDeJong
Mentor
Mentor

I could not open your files because i use an older version of inventor (2018) then you, but i think i found why you get the error. When i looked a bit closer at the img in you opening post i saw that you where using a "Ordinate Dimension Set" in stead of a "Ordinate Dimension". it is not a problem to delete a "Ordinate Dimension" but i could not find a way to remove a member of an "Ordinate Dimension Set". I only found a way to delete the complete "Ordinate Dimension Set".

Here the code to delete all "Ordinate Dimensions" that are not attached. And that will remove all "Ordinate Dimension Sets" if 1 or more members is not attached.

Dim setsToDelete As List(Of OrdinateDimensionSet) = New List(Of OrdinateDimensionSet)()
For Each oOrdDim As OrdinateDimension In oSheet.DrawingDimensions.OrdinateDimensions
    If (oOrdDim.Attached = False) Then
        If (oOrdDim.IsOrdinateSetMember = False) Then
            oOrdDim.Delete()
        Else
			If (setsToDelete.Contains(oOrdDim.OrdinateDimensionSet) = False) Then
                setsToDelete.Add(oOrdDim.OrdinateDimensionSet)
            End If
        End If

    End If 'Baloon attached
Next
For Each ordinateDimensionSet As OrdinateDimensionSet In setsToDelete
    ordinateDimensionSet.Delete()
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 7

ralfmja
Advocate
Advocate

 

Of course you are right about the Ordinate Dimension Set 🙂

 

Have you tried the code you proposed?

 

After entering it in the rule, the error disappeared but the dimensions, unfortunately, have not been removed.

 

Do you have any other idea ??

0 Likes
Message 6 of 7

JelteDeJong
Mentor
Mentor
Accepted solution

Hi,

i tryed the code i proposed. and it works for me as described. Is it possible that you dont have not attached ordinate dimensions. you could comment out the lines for that check. (like it was in your code in the opening post.) then it should delete evry thing without reservations.

 

Dim doc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = doc.ActiveSheet

Dim setsToDelete As List(Of OrdinateDimensionSet) = New List(Of OrdinateDimensionSet)()
For Each oOrdDim As OrdinateDimension In oSheet.DrawingDimensions.OrdinateDimensions
    'If (oOrdDim.Attached = False) Then
        If (oOrdDim.IsOrdinateSetMember = False) Then
            oOrdDim.Delete()
        Else
			If (setsToDelete.Contains(oOrdDim.OrdinateDimensionSet) = False) Then
                setsToDelete.Add(oOrdDim.OrdinateDimensionSet)
            End If
        End If

    'End If 'Baloon attached
Next
For Each ordinateDimensionSet As OrdinateDimensionSet In setsToDelete
    ordinateDimensionSet.Delete()
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 7 of 7

ralfmja
Advocate
Advocate

Yes - that's what was missing 🙂

 

Thank you very much for your time !! 

 

Greetings,

Rafal

0 Likes