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: 

Dimension of Parts instead of Sketches

1 REPLY 1
SOLVED
Reply
Message 1 of 2
mohnish_soral
292 Views, 1 Reply

Dimension of Parts instead of Sketches

I have tried to write a code for getting the part Dimension which get placed in Inventor , I have used Inventor API to retrieve the dimension

The problem is when I use this API , I get all the dimension including Sketch dimension and Part Dimension, but I want that my Drawing sheet should only contain Part dimension not Sketch dimension.

I have tried many ways to get rid of this problem but fail to do so
I also thought to delete the dimension once appear on drawing sheet but unable to do so


This is my code snippet

foreach (DrawingView view in drawingSheet.DrawingViews)
       {
            DrawingView view1 = drawingDoc.ActiveSheet.DrawingViews[1];
            drawingDoc.ActiveSheet.DrawingDimensions.GeneralDimensions.Retrieve(view1);

               for (int i = drawingDoc.ActiveSheet.DrawingDimensions.GeneralDimensions.Count; i > 0; i--)
                   {
                         GeneralDimension dimension = drawingDoc.ActiveSheet.DrawingDimensions.GeneralDimensions[i];

                         if (dimension.Type == ObjectTypeEnum.) //Don't know what to right after .
                               {
                                   dimension.Delete();
                               }
                    }
       }

 

I don't know is my method wrong or write , I am not sure what to write in this line 

(dimension.Type == ObjectTypeEnum.)

 

After ObjectTypeEnum such that I can get rid of sketch dimension from Drawing sheet
Also if someone suggest some different and better way for viewing dimension will be a great pleasure

Thankyou in Advance

1 REPLY 1
Message 2 of 2

It can be much easier to retrieve only wanted dimensions. You can try this code which retrieves only FeatureDimensions from model

 

private GeneralDimensionsEnumerator RetrieveModelDimensions(DrawingView drawingView)
{
    var sheet = drawingView.Parent;
    var app = sheet.Application as Inventor.Application;

    var generalDimensions = sheet.DrawingDimensions.GeneralDimensions;

    var dimensionsToRetrieve = app.TransientObjects.CreateObjectCollection();
    var retrievableDimensions = generalDimensions.GetRetrievableDimensions(drawingView, null);
    foreach (dynamic dimension in retrievableDimensions)
    {
        var type = dimension.Type;
        //var name = Enum.GetName(typeof(ObjectTypeEnum), type);
        if (type == (int)ObjectTypeEnum.kFeatureDimensionObject ||
            type == (int)ObjectTypeEnum.kFeatureDimensionProxyObject)
            dimensionsToRetrieve.Add(dimension);
    }

    var retrievedDimensions = generalDimensions.Retrieve(drawingView, dimensionsToRetrieve);
    return retrievedDimensions;
}

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report