Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Retrieve dimensions

21 REPLIES 21
SOLVED
Reply
Message 1 of 22
theo.bot
4660 Views, 21 Replies

Retrieve dimensions

Hi,

 

I want to retrieve dimensions in a drawing with ilogic. I found some code in de api help, but i can't figure out how to translate it into a ilogic code.

 

I always use assembly models in these drawing and all the parameters have unique names. So in my drawing i want to retrieve some specific dimensions in a view.

 

Can anyone point me in the right direction? maybe a small sample?

 

kind regards,

 

theo

Tags (3)
21 REPLIES 21
Message 21 of 22
Prasad.pet
in reply to: marco_suurlant

Hi Macro Surlant

 

The code will not work in some partlicular condition, where the inside "For ...Loop execute for another time in a complex model.

But it will work for the simpler model. But due the necessity I tried my level best and found out the solution for that.

 

I hope this code would be generic but still I expect few of the our community member to give the assuarance on that.

 

Thank you.  Following is the altered code. This code is written in VB.Net kindly modify based on your programming language

 

Regards

Prasad

 

 

 

' Set a reference to the active drawing document

Dim oDrawDoc As Inventor.DrawingDocument

Dim oSheet As Inventor.Sheet

Dim oDrawView As Inventor.DrawingView

Dim oGeneralDimensionsEnum As Inventor.GeneralDimensionsEnumerator

Dim oGeneralDimension As Inventor.GeneralDimension

 

oDrawDoc = inventorApp.ActiveDocument

oSheet = oDrawDoc.ActiveSheet

oDrawView = oSheet.DrawingViews(1)

 

oGeneralDimensionsEnum = oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oDrawView)

Dim PrefixStr AsString = "RetD_"

 

ForEach oGeneralDimension InoGeneralDimensionsEnum

 

 Dim oParameter As Inventor.Parameter

 oParameter = oGeneralDimension.RetrievedFrom.Parameter

 If oParameter.DrivenBy.Count <> 0 Then

    Dim oDrivenByParameter As Inventor.Parameter

    '''This Loop needed Special care - Prasad

    ForEach oDrivenByParameter InoParameter.DrivenBy

        If InStr(oDrivenByParameter.Name, PrefixStr) = 0 Then

                    oGeneralDimension.Delete()

        EndIf

        Exit For ''(This is the extra line needed)- Prasad

    Next

 

 Else

     If InStr(oParameter.Name, PrefixStr) = 0 Then

                oGeneralDimension.Delete()

     EndIf

EndIf

 

Next

Message 22 of 22
pabloVBDH9
in reply to: marco_suurlant

I'm sorry for re-opening this post. First of all thanks for your code, it's really helpfull for me. But I'd like to change it a little bit and I was wondering if you could help me out.

 

The thing is that I'd like the workflow to be diferent. Instead of retrieving them all and then erase unwanted, I need to retrieve just the named dimensions.

The problem I'm experiencing is that when I use the rule on big assemblies, even if i just want to retrieve a couple o dim's, it takes too much time 'cause it's retrieving all the dimensions in there and then erasing. 

I guess retrieving only the named dim's would help get things faster, is that right?

 

Here I post the code I'm using... which is basically your code 🙂

Thanks in advance

 

SyntaxEditor Code Snippet

oDrawView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter , "SELECCIONA UNA VISTA")
Dim PrefixStr As String = InputBox("PREFIJO DE COTAS A OBTENER.............(Dejar en blanco para obtener todas o escribir p para obtener las generadas con iLogic)", "RECUPERADOR DE COTAS", "p")
Dim oDrawDoc As DrawingDocument = ThisDoc.Document 
Dim oSheet As Sheet = oDrawDoc.ActiveSheet 
Dim oGeneralDimensionsEnum As GeneralDimensionsEnumerator
oGeneralDimensionsEnum = oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oDrawView)
Dim oGeneralDimension As GeneralDimension
For Each oGeneralDimension In oGeneralDimensionsEnum
    Dim oParameter As Parameter
    oParameter = oGeneralDimension.RetrievedFrom.Parameter
 
    If oParameter.DrivenBy.count <> 0 Then
        Dim oDrivenByParameter As Parameter
        For Each oDrivenByParameter In oParameter.DrivenBy
            If InStr(oDrivenByParameter.Name, PrefixStr) = 0 Then
                oGeneralDimension.Delete
            End If
        Next
                Else
        If InStr(oParameter.Name, PrefixStr) = 0 Then
            oGeneralDimension.Delete
        End If
    End If
Next
 

 

Un saludo

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

Post to forums  

Autodesk Design & Make Report