Retrieve dimension very slow

Retrieve dimension very slow

johnster100
Collaborator Collaborator
509 Views
4 Replies
Message 1 of 5

Retrieve dimension very slow

johnster100
Collaborator
Collaborator

Hi,

i'm using the code:

oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oView, oObjColl)

 

to retrieve dimensions in a drawing. The problem is it's taking a long time to run this part of code (and i run it several times).

 

The code is being used in an assembly and it has lots of occurrences made from multi-solid body components. I believe it's these that are causing the delay. 

 

Is there a way to get round this?

 

thanks,

John

0 Likes
510 Views
4 Replies
Replies (4)
Message 2 of 5

johnster100
Collaborator
Collaborator

i've created an example which shows it crashing when trying to retrieve all the dims from an oCC.

 

If I try and get a dim from a sketch it's still very slow.

 

thanks again,

John

0 Likes
Message 3 of 5

johnster100
Collaborator
Collaborator

any help available on this?

0 Likes
Message 4 of 5

laszlo_nagy
Contributor
Contributor

Hi,

 

If I understand correctly, you want the dimmension only for "Solid1:1" CompOccurrence ?

(my code below)

 

In your Code, in the last row, you use wrong arguments for .GeneralDimensions.Retrieve  this is why Inventor Frozen

 

 

After arranging the dimmensions I got this result:

Unbenannt.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

My Code in VBA:

 

Sub Test()

Dim oSheet As Sheet
Set oSheet = ThisApplication.ActiveDocument.ActiveSheet

Dim oView As DrawingView
Set oView = oSheet.DrawingViews.Item(1)

Dim oAssy As Inventor.AssemblyComponentDefinition
Set oAssy = oView.ReferencedDocumentDescriptor.ReferencedDocument.ComponentDefinition

Dim compOcc As Inventor.ComponentOccurrence

For Each oCC In oAssy.Occurrences.AllLeafOccurrences()
    If oCC.Name = "Solid1:1" Then
        Set compOcc = oCC
        Exit For
    End If
Next

Dim oObjColl As Inventor.ObjectCollection
Set oObjColl = ThisApplication.TransientObjects.CreateObjectCollection

'Add All Retrievable Dim
Dim oObjCollAllDim As Inventor.ObjectCollection
Set oObjCollAllDim = oSheet.DrawingDimensions.GeneralDimensions.GetRetrievableDimensions(oView)

'Select Dim which are Connected To "Solid:1"
For Each obj In oObjCollAllDim
    If obj.ContainingOccurrence Is compOcc Then
         Call oObjColl.Add(obj)
    End If
Next


Call oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oView, oObjColl)
   
End Sub

 

 

 

0 Likes
Message 5 of 5

johnster100
Collaborator
Collaborator

Hi,

thanks a lot for the reply.

 

When I try this code on my actual model(it's a lot more complex)  it's very slow (several minutes) at the line:

oSheet.DrawingDimensions.GeneralDimensions.GetRetrievableDimensions(oView)

 

I also tried putting the Component Occurrence for the part in as the optional input but this was still slow.

 

thanks again,

John

0 Likes