Below some working sample code. I tried it with the attached TrimSurf.dwg.
Register void cmdTrim() as a command, load TrimSurf.dwg, select the cone when prompted to select a surface and the red circle or/and the blue pline when prompted to select trimming entities. The area around the point where you picked the surface will be removed.
This sample uses the current view direction as projection direction for all trimcurves.
static long ssetToObjIdArray(ads_name sset, AcDbObjectIdArray &objIdArr);
void cmdTrim()
{
ads_point pt;
ads_name ent;
AcDbObjectId blankSurfaceId; //Original input surface to be trimmed.
if (acedEntSel(_T("\nSelect surface: "), ent, pt) != RTNORM)
return;
if (acdbGetObjectId(blankSurfaceId, ent) != Acad::eOk) //ads_name-->AcDbObjectId
return;
// Is it a surface?
Acad::ErrorStatus es;
AcDbSurface *pSurf = 0;
if ((es = acdbOpenObject(pSurf, blankSurfaceId, AcDb::kForRead)) == Acad::eOk)
{
pSurf->close(); // yep
}
else
{
acutPrintf(L"\nNot a surface.");
return;
}
// transform pt from UCS to WCS
ads_point ptWcs, zAxis = { 0.0, 0.0, 1.0 }, vView;
acdbUcs2Wcs(pt, ptWcs, Adesk::kFalse);
// calculate the current viewing direction
struct resbuf wcs, dcs;
wcs.restype = RTSHORT; wcs.resval.rint = 0;
dcs.restype = RTSHORT; dcs.resval.rint = 2;
acedTrans(zAxis, &dcs, &wcs, 1, vView);
AcGeVector3d vViewDir(vView[X], vView[Y], vView[Z]);
//AcDbObjectId blankSurfaceId //Original input surface to be trimmed.
AcDbObjectIdArray toolIds; //array of ids of cutting entities that their bodies will be directly
//used to trim the surface without further treatment such as projection.
AcDbObjectIdArray toolCurveIds; //array of ids of cutting curves that will be used to trim the surface
// by first projecting them to the surface
AcArray<AcGeVector3d> projVectors; //array of projection direction of each cutting curve in toolCurveIds,
//so the length of projVectors should be equal to the length of toolCurveIds
AcGePoint3d pickPoint(ptWcs[X], ptWcs[Y], ptWcs[Z]); //pick point that is used to specify which area of a surface should be trimmed.
AcGeVector3d viewVector(vViewDir); //when using pick point to find out which area to trim, caller should
//also specify the view direction which will be used form a ray starting
//from the pick point in the view direction and see which area is hit by the ray first.
bool bAutoExtend = false; //If this option is set then when a tool body consists of a single face
//with analytic geometry, the underlying geometry will be extended as
//much as possible to make sure the surface is trimmed.The tool body
//supplied will not be modified.
bool bAssociativeEnabled = false; //Specifies whether the surface trimming operation should be associative.
// Select the trim-entities
ads_name sset = { 0,0 }; // The selectionset
acutPrintf(_T("\nSelect trimming entities: "));
if (acedSSGet(NULL, NULL, NULL, NULL, sset) == RTNORM)
{
ssetToObjIdArray(sset, toolCurveIds);
// leave toolIds empty for this example.
acedSSFree(sset);
}
// Use Viewdir as projection direction
int i, nCountTrimCurves = toolCurveIds.length();
projVectors.setLogicalLength(nCountTrimCurves);
for (i = 0; i < nCountTrimCurves; ++i)
projVectors[i] = viewVector;
bAutoExtend = false;
bAssociativeEnabled = false;
// Let's go:
es = AcDbSurface::trimSurface(blankSurfaceId, toolIds, toolCurveIds, projVectors, pickPoint, viewVector, bAutoExtend, bAssociativeEnabled);
}
static long ssetToObjIdArray(ads_name sset, AcDbObjectIdArray &objIdArr)
{
long selSetLen = 0, i;
if (acedSSLength(sset, &selSetLen) != RTNORM)
return -1;
ads_name ename;
AcDbObjectId objId;
for (i = 0; i<selSetLen; i++) // Für alle Entities im Selection-Set
{
if (acedSSName(sset, i, ename) == RTNORM)
{
if (acdbGetObjectId(objId, ename) == Acad::eOk)
objIdArr.append(objId);
}
}
return selSetLen;
}
Thomas Brammer ● Software Developer ● imos AG ● LinkedIn ● 
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.