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: 

pSketch->Name and pSketch->get_Name

1 REPLY 1
Reply
Message 1 of 2
oransen
335 Views, 1 Reply

pSketch->Name and pSketch->get_Name

I know this is similar to another post of mine (Why GetOccurrences and get_Occurrences?) but since I'm also new to smart pointers I thought I'd better sort this out in my mind.

 

When manipulating the name of a sketch I can use three different ways of doing it.

 

 

    hRes = pSketches->Add (_variant_t((IDispatch *)pWorkPlane),
                           VARIANT_FALSE,
                           &pSketch);
    wprintf (L"The sketch default name is %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) ;

 So I can use

  1.     pSketch->Name // to get the name  for a printf for example
  2.     pSketch->Name = L"Tube-Base" ; // to set the name
  3.     pSketch->get_Name (&bstrSketchName) ; // to get the name

I understand why there is get_ and Get, but why is the Name and get_Name? Is it a smart pointer thing I need to be wary of? Or can I simply use these methods as I have done in the code example above?

 

 

1 REPLY 1
Message 2 of 2
philippe.leefsma
in reply to: oransen

Hi Oransen,

 

In C++ all the methods come in two flavor, that are named high and low syntax: the high syntax methods are the GetXXXX ones, they usually return directly the result but throw exceptions. The low syntax methods are the get_XXXX ones. They returned error code and take the result as in-out parameter.

 

Both low and high methods have the same effect, but it is usually a good practice to remain consistent wether you use one or the other.

 

Regrads,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report