Help Needed to Integrate ObjectArx Code in .NET Project

Help Needed to Integrate ObjectArx Code in .NET Project

artillis_prado
Enthusiast Enthusiast
383 Views
1 Reply
Message 1 of 2

Help Needed to Integrate ObjectArx Code in .NET Project

artillis_prado
Enthusiast
Enthusiast

Hello everyone!

I'm a beginner in studying ObjectArx, and in the image below, I managed to create a project and configure it with the ObjectArx packages.

I found the code below on the .NET forum and would like to know how to make it work in my project.

artillis_prado_0-1720558270190.png

 

 

void CrearGruposPaletas()
{
    TCHAR datosGrupos[1000];
   //TCHAR * datosGrupos=L"Grupo3|Grupo2";
	
   CString grupoNuevo;
   CString grupoPadre;
   CString pElem[50];
   int res;
   bool ok;
   CAcTcUiToolPaletteSet *pTPSet = AcTcUiGetToolPaletteWindow();
   CAcTcUiToolPaletteGroup *pPaletteGroups = pTPSet->GetToolPaletteGroup(true); 
   CAcTcUiToolPaletteGroup *pPaletteGroupNuevo;
   CAcTcUiToolPaletteGroup *pPaletteGroupPadre;

   res= acedGetString (1, _T("\nDatos de grupo: "), datosGrupos);
   res=SplitString(datosGrupos,_T("|"),pElem);

   //Formato: NombreGrupo|GrupoPadre
   if (res == 2)
   {
		grupoNuevo= pElem[0];
		grupoPadre=pElem[1];

               pPaletteGroupNuevo = pPaletteGroups->FindGroup(grupoNuevo,true);    
               if (pPaletteGroupNuevo == NULL)    
               {
                   // No existe el grupo, se creara uno nuevo

	           //Clonar el grupo general y borrarle los elementos para que sea el nuevo grupo a agregar
	           ok = pPaletteGroups->Clone(pPaletteGroupNuevo);
	           if (ok)
	           {
			ok = pPaletteGroupNuevo->DeleteAllItems();
		    }

		    if (ok)
		    {
		       //Asignarle el nombre al nuevo grupo
		       ok=pPaletteGroupNuevo->SetName(grupoNuevo);
		       //Buscar el grupo padre y asignarle el nuevo
		       pPaletteGroupPadre=pPaletteGroups->FindGroup(grupoPadre,true);
		       if (pPaletteGroupPadre != NULL)
		       {
			  res=pPaletteGroupPadre->AddItem(pPaletteGroupNuevo);
		       }
		    } 
               }
   }
  else if(res==1)
  {
    //Si no aparece GrupoPadre es el raiz
	grupoNuevo = pElem[0];

    pPaletteGroupNuevo = pPaletteGroups->FindGroup(grupoNuevo,true);    
    if (pPaletteGroupNuevo == NULL)    
    {
		// No existe el grupo, se creara uno nuevo

		//Clonar el grupo general y borrarle los elementos para que sea el nuevo grupo a agregar
		ok = pPaletteGroups->Clone(pPaletteGroupNuevo);
		if (ok)
		{
			ok = pPaletteGroupNuevo->DeleteAllItems();
		}

		if (ok)
		{
			  //Si no aparece GrupoPadre es el raiz
			  grupoNuevo= pElem[0];
			  ok=pPaletteGroupNuevo->SetName(grupoNuevo);
			  res=pPaletteGroups->AddItem(pPaletteGroupNuevo);
		}
    }
  }	
}

 


 

0 Likes
384 Views
1 Reply
Reply (1)
Message 2 of 2

daniel_cadext
Advisor
Advisor

Aren’t tool palettes exposed to .NET already?

 

For a single mixed C++ARX / Managed DLL, you must use C++/CLI as the language. This is how the wrappers are created in the first place.

https://learn.microsoft.com/en-us/cpp/dotnet/mixed-native-and-managed-assemblies?view=msvc-170

 

I have some projects I did long ago that may give you a hint over at the swamp. Also see, ARXSDK\samples\entity\polysamp\managed

 

 

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes