owenransen 14 Newbie Poster

WARNING: If you don't like horribly messy questions don't read on...

Autodesk Inventor is a 3D parametric CAD program and plugins can be made using COM. I have no experience with COM and some of my naive COM type questions go ignored in the Inventor forums...

Look at this:

  hRes = pSketches->Add (_variant_t((IDispatch *)pWorkPlane),
                         VARIANT_FALSE,
                         pSketch);
  wprintf (L"Sketch name: %s\n",pSketch->Name.GetBSTR()) ;

  pSketch->Name = L"Tube-Base" ;

  BSTR bstrSketchName ;
  pSketch->get_Name (&bstrSketchName) ;
  wprintf (L"The sketch is now called %s\n",bstrSketchName) ;

The above code shows how to get and change the name of a "Sketch" in different ways.

Basically there is pSketch->Name which is read and write, while pSketch->get_Name(&Name) is a read operation.

My question is: after using pSketch->Name do I have to do any .Release of smart pointers or anything?

Autodesk seems to have created double ways of accessing the same thing. With pointers you can use the

ptr = pObject->Get3D() ;

or

HRESULT hRes = pObject->get_3D(&ptr) ;

They reccommend the later because it does not throw exceptions. And the former I think uses smart pointers which I'm too stupid to understand.

Has anybody come across this way of doing things in COM?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.