Example of creating a dimension in a sheet from objects in an assembly

Example of creating a dimension in a sheet from objects in an assembly

oransen
Collaborator Collaborator
2,457 Views
12 Replies
Message 1 of 13

Example of creating a dimension in a sheet from objects in an assembly

oransen
Collaborator
Collaborator

I have an assembly, tube with some other components attached to it. I'd like to add tube diameter and length dimensions to the sheet.

 

I can't find an example of how to do this. The examples I've found seem to start with know objects and use get_Item(1).

 

So is there an example of creating a dimension in a sheet from objects in an assembly?

 

I need a complete worked example because my knowledge is so fragmentary I feel as if I'm falling apart:

 

CreateGeometryIntent,  GeometryIntent, DrawingCurves, EdgeProxy/FaceProxy and so on.

0 Likes
Accepted solutions (1)
2,458 Views
12 Replies
Replies (12)
Message 2 of 13

Balaji_Ram
Alumni
Alumni

Hi Owen,

 

It is possible to choose which of the dimensional constraints get shown in a view using the Retrieve method.

This forum post should provide a code snippet to use that method. 

 

http://forums.autodesk.com/t5/inventor-customization/retrieve-slected-dimension-in-view-with-vba/m-p...

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 13

oransen
Collaborator
Collaborator

This is not exactly what I need.

 

Is there no tech article which explains the complete background and details of creating dimensions in an IDW from an IAM? Preferably with diagrams...?

 

0 Likes
Message 4 of 13

Balaji_Ram
Alumni
Alumni

Not that i am aware of.

 

When you say "add tube diameter and length dimensions to the sheet" I had interpreted your query as

retrieving the model dimensions which already exist in the assembly to show up in a view inside a sheet.

 

This is similar to using the "Retrieve dimensions" from the context menu in Inventor UI and then use

"Select dimensions" to only retain the ones that we need.

 

If you can clarify more on exactly what you are trying, I will try and find out if there is any information on that topic.

 

Regards,

Balaji

 

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 13

oransen
Collaborator
Collaborator

There are actually two problems, but for this post lets stick to one.

 

I'm now able to use GetRetrievableDimensions to get an object collection validly. My next specific question:

 

How I add selected dimensions into the actual IDW drawing file?

 

    hRes = pGenDims->GetRetrievableDimensions (pThisView,gkvarEmpty,&pObjCollection) ;
    if (FAILED (hRes)) {
         gLogger.Printf (ekErrMsg,"Could not get ret dims") ;

    }

    // So nowI have the object collection, how do I add...

    // them into the DrawingDocument?

 

 

 

 

0 Likes
Message 6 of 13

Balaji_Ram
Alumni
Alumni

Hi Owen,

 

I am working on this and will get back to you. 

 

Retrieving all the dimensions is straight forward and this should work, but i will need to check on the second parameter to retrieve only a few of the retrievable dimensions.

 

				CComPtr<GeneralDimensionsEnumerator> pGenDimsEnum;
				hr = pGenDimensions->Retrieve(pDrawingView, CComVariant(), &pGenDimsEnum);

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 7 of 13

oransen
Collaborator
Collaborator
Many thanks! I await with baited breath and anxious eyes!
0 Likes
Message 8 of 13

Balaji_Ram
Alumni
Alumni
Accepted solution

Hi Owen,

 

Here is a code snippet to retrieve only a few of the retrievable dimensions

 

// Retrieve only a few of the retrievable dimensions
CComPtr<ObjectCollection> pObjCollection; 
hr = pInvApp->TransientObjects->CreateObjectCollection(CComVariant(), &pObjCollection); 

IDispatchPtr pDim;
hr = pObjColl->get_Item(_variant_t(1), &pDim);
pObjCollection->Add(pDim);
CComPtr<GeneralDimensionsEnumerator> pGenDimsEnum1;
hr = pGenDimensions->Retrieve(pDrawingView, CComVariant(pObjCollection), &pGenDimsEnum1);

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 9 of 13

oransen
Collaborator
Collaborator

Thanks, that answers part of my original question:

 

How I add selected dimensions into the actual IDW drawing file?

 

Is there an example of adding them into the IDW file?

 

0 Likes
Message 10 of 13

Balaji_Ram
Alumni
Alumni

Hi Owen,

 

Do you mean creating a new drawing document and inserting a base view in it ?

 

http://adndevblog.typepad.com/manufacturing/2012/06/creating-drawing-views-via-the-inventor-api.html

 

After the base view has been inserted, the code to retrieve a few of the retrievable dimensions should work.

 

Regards,

Balaji

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 11 of 13

oransen
Collaborator
Collaborator

I'm not at that computer at the moment... 😞

 

So you mean that Retrieval actually places the dims in the IDW? I'll let you know more tomorrow when I can experimnt. In the meantime thanks for your help.

0 Likes
Message 12 of 13

Balaji_Ram
Alumni
Alumni

No problem, please let me know after you get a chance to try it.

 

Yes, it does.

 

Please try running the code with a drawing document as active and the view should show up that dimension.

 

Regards,

Balaji

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 13 of 13

oransen
Collaborator
Collaborator
Yep! That did it, thanks!
0 Likes