Hello
I have a problem with inventor 2022 VBA macro. I can’t delete unattached drawing dimensions because all members attached value is True. But it shouldn’t be.
Is it Inventor 2022 bug or do i need to find new solution to delete unattached dimensions?
Solved! Go to Solution.
Solved by CattabianiI. Go to Solution.
Could you please share a sample drawing with this issue?
Doing few tests on my side Attached property seems ok
Instead of deleting centerlines, can you try below?
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet = oDoc.ActiveSheet Dim oDim As DrawingDimension For Each oDim In oSheet.DrawingDimensions If oDim.Attached = False oDim.Delete End If Next
Try finding the dimensions that are not attached, the code is in VB.Net, you need to convert it in VBA, see if that helps.
Problem is chain dimensions set. I guess that if they have some point attached then it would be like all the points are attached. It started when my firm updated 2021 vers. to 2022 vers.
I added also some sample file.
Create 1 try/ catch function
OrdinateDimensionSets
Best Reagards Johan
Dim oSheet As Sheet = ThisDoc.Document.ActiveSheet Try Dim oDim As GeneralDimension For Each oDim In oSheet.DrawingDimensions If oDim.Attached = False oDim.Delete End If Next Catch Dim oDim As OrdinateDimensionSet For Each oDim In oSheet.DrawingDimensions.OrdinateDimensionSets If oDim.Attached = False oDim.Delete End If Next End Try
Hi @matinael,
I tested your macro in Inventor 2020 and it has the same behaviour of Inventor 2022.
I came here just for the Inv 2022 update thing and it wasn't true. 😑
BTW, this is how to delete chain set dimensions in case of unattached points.
TL;DR: Check Intents and if it fails then merge dimensions.
Dim drwdoc As DrawingDocument = ThisApplication.ActiveDocument
For Each chainDim As ChainDimensionSet In drwdoc.ActiveSheet.DrawingDimensions.ChainDimensionSets
Dim i = 0
For Each genDim As GeneralDimension In chainDim.Members
Try
i = i + 1
' I didn't test if this cast could fail sometimes.
' [?] maybe angular dimension in chain set? Is it possible? I don't know!
Dim linearDim As LinearGeneralDimension = TryCast(genDim, LinearGeneralDimension)
If linearDim Is Nothing Then
Continue For
End If
Try
Dim intent As GeometryIntent = linearDim.IntentOne
Catch
' Cannot retrieve the first geometry associated with the dimension
If i = 1 Then
' If it's the most left intent missing, I cannot merge dimensions so I delete it
linearDim.Delete()
Else
chainDim.MergeMembers(chainDim.Members(i - 1), linearDim)
End If
' Update the counter
i = i - 1
End Try
' Working with last dimension
If i = chainDim.Members.Count Then
Dim latestDim As LinearGeneralDimension = chainDim.Members(i)
Try
Dim intent As GeometryIntent = latestDim.IntentTwo
Catch
' it's the last intent missing so I delete the dimension
latestDim.Delete()
End Try
Return
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Next
Next
Can't find what you're looking for? Ask the community or share your knowledge.