The type of the second parameter in GetRetrievableDimensions (COM C++) ?

The type of the second parameter in GetRetrievableDimensions (COM C++) ?

oransen
Collaborator Collaborator
500 Views
5 Replies
Message 1 of 6

The type of the second parameter in GetRetrievableDimensions (COM C++) ?

oransen
Collaborator
Collaborator

Hello All...

What is the type of the second parameter in a call to GetRetrievableDimensions? Is it a PartComponentDefinition pointer or a PartDocument pointer or...?

      

        CComPtr<ObjectCollection> pAllRetCollection = nullptr;
        hRes = pGenDims->GetRetrievableDimensions(pThisView,
                                                  ??? what goes here???,
                                                  &pAllRetCollection);

TIA

 

 

 

 

 

0 Likes
Accepted solutions (1)
501 Views
5 Replies
Replies (5)
Message 2 of 6

CattabianiI
Collaborator
Collaborator

From the manual

[...] Valid inputs include PlanarSketch, any of the objects that derive from PartFeature, ComponentOccurrence and the proxies to all these objects. [...]
This is an optional argument whose default value is null.

0 Likes
Message 3 of 6

oransen
Collaborator
Collaborator

Believe it or not I HAVE read the manual, but it is no help as far as COM C++ is concerned.

Hopefully you can give me an example in C++/COM....?

My experiements with Parts and Part definitions and occurrences have failed so far.

 

 


@CattabianiIwrote:

From the manual

[...] Valid inputs include PlanarSketch, any of the objects that derive from PartFeature, ComponentOccurrence and the proxies to all these objects. [...]
This is an optional argument whose default value is null.


 

0 Likes
Message 4 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@oransen,

 

Try below C++ code to retrieve dimensions from a drawing view.

 

	CComPtr<Document> pDoc;
	Result = pInvApp->get_ActiveDocument(&pDoc);

	CComPtr<DrawingDocument> pDrawDoc;
	pDrawDoc = pDoc;

	CComPtr<Sheet> Draw_Sheet;
	Result = pDrawDoc->get_ActiveSheet(&Draw_Sheet); 

	DrawingViewsPtr draw_Views;
	Result = Draw_Sheet->get_DrawingViews(&draw_Views);
		
	DrawingViewPtr Draw_View;
	Result = draw_Views->get_Item(1, &Draw_View);

	DrawingDimensionsPtr Draw_Dims;
	Result = Draw_Sheet->get_DrawingDimensions(&Draw_Dims);

	GeneralDimensionsPtr draw_Gen_Dims;
	Result = Draw_Dims->get_GeneralDimensions(&draw_Gen_Dims);

	CComPtr<ObjectCollection> pObjCollection;
	Result = draw_Gen_Dims->GetRetrievableDimensions(Draw_View, CComVariant(), &pObjCollection);
	
	long no_of_Retrieved_Dim = 0;
	if (pObjCollection != NULL)
	{
		Result = pObjCollection->get_Count(&no_of_Retrieved_Dim);

	}

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Likes".

 

Thanks and regards,

 


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 5 of 6

oransen
Collaborator
Collaborator

Thanks for the reply. But your call to

 

draw_Gen_Dims->GetRetrievableDimensions(Draw_View, CComVariant(), &pObjCollection);
	

has an empty 2nd parameter which means all the dimensions will be retrieved. The docs says that if it is not an empty null parameter it can be an occurrence, but give no more details.

 

 

0 Likes
Message 6 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support

@oransen,

 

Try below C++ code to retrieve dimensions of occurrence from Drawing document. This code is tested with attached sample drawing.

 

	CComPtr<Document> pDoc;
	Result = pInvApp->get_ActiveDocument(&pDoc);

	CComPtr<DrawingDocument> pDrawDoc;
	pDrawDoc = pDoc;

	CComPtr<Sheet> Draw_Sheet;
	Result = pDrawDoc->get_ActiveSheet(&Draw_Sheet); 

	DrawingViewsPtr draw_Views;
	Result = Draw_Sheet->get_DrawingViews(&draw_Views);
		
	DrawingViewPtr Draw_View;
	Result = draw_Views->get_Item(1, &Draw_View);

	IDispatchPtr pReferDoc;
	Result = Draw_View->ReferencedDocumentDescriptor->get_ReferencedDocument(&pReferDoc);

	CComQIPtr<Document> pReferDocument = CComQIPtr<Document>(pReferDoc); 
		 
	CComQIPtr<AssemblyDocument> pAssyDoc;
	pAssyDoc = pReferDocument;

	CComPtr<AssemblyComponentDefinition> pAssDef;
	Result = pAssyDoc->get_ComponentDefinition(&pAssDef);

	CComPtr<ComponentOccurrence> pOcc;
	Result = pAssDef->Occurrences->get_Item(1, &pOcc);
	 

	DrawingDimensionsPtr Draw_Dims;
	Result = Draw_Sheet->get_DrawingDimensions(&Draw_Dims);

	GeneralDimensionsPtr draw_Gen_Dims;
	Result = Draw_Dims->get_GeneralDimensions(&draw_Gen_Dims);

	CComPtr<ObjectCollection> pObjCollection;	
	
	CComPtr<ObjectCollection> pGenDimsEnum;
	Result = draw_Gen_Dims->GetRetrievableDimensions(Draw_View, _variant_t((IDispatch*)pOcc), &pObjCollection);
	
	long no_of_Retrieved_Dim = 0;
	if (pObjCollection != NULL)
	{
		Result = pObjCollection->get_Count(&no_of_Retrieved_Dim);

	}

	return S_OK;

Please feel free to contact if there is any queries.

 

If solves problem, click on 'Accept as solution' / give a 'Like'.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes