Hi Guys,
i'm struggling with this for one day now and can't figure it out
the program fails on trying to add the attrib object
what am i doing wrong?
thanks in advanced
moshe
static int make_anonymous_attribute_block () { struct resbuf *entlist = NULL; int status; ads_point pt0 = {0.0, 0.0, 0.0}; entlist = acutBuildList( RTDXF0, _T("BLOCK"), 100, _T("AcDbEntity"), 8, _T("0"), 100, _T("AcDbBlockBegin"), 70, 3, 10, pt0, 2, _T("*U"), 1, _T(""), 0 ); if (entlist == NULL) return RTERROR; if ((status = acdbEntMake(entlist)) != RTNORM) { acutRelRb(entlist); return status; } acutRelRb(entlist); entlist = acutBuildList( RTDXF0, _T("CIRCLE"), 8, _T("0"), 10, pt0, 40, 0.22, 0); if (entlist == NULL) return RTERROR; if ((status = acdbEntMake(entlist)) != RTNORM) { acutRelRb(entlist); return status; } acutRelRb(entlist); entlist = acutBuildList( RTDXF0, _T("ATTDEF"), 100, _T("AcDbEntity"), 8, _T("0"), 100, _T("AcDbText"), // 10, pt0, 40, 0.16, 1, _T(""), 50, 0.0, 41, 1.0, 51, 0.0, 7, _T("STANDARD"), 100, _T("AcDbAttributeDefinition"), 3, _T("Attribute value"), 2, _T("NAME"), 70, 0, 71, 0, 72, 4, 73, 0, 74, 4, 11, pt0, 0); if (entlist == NULL) return RTERROR; if ((status = acdbEntMake(entlist)) != RTNORM) { acutRelRb(entlist); return status; } acutRelRb(entlist); entlist = acutBuildList( RTDXF0, _T("ENDBLK"), 100, _T("AcDbEntity"), 8, _T("0"), 100, _T("AcDbBlockEnd"), 0); if (entlist == NULL) return RTERROR; if ((status = acdbEntMake(entlist)) != RTKWORD) { acutRelRb(entlist); return status; } acutRelRb(entlist); ACHAR anonBlockName[32] = {0}; if ((status = acedGetInput(anonBlockName)) != RTNORM) return status; // insert anonymous block entlist = acutBuildList( RTDXF0, _T("INSERT"), 100, _T("AcDbEntity"), 8, _T("0"), 100, _T("AcDbBlockReference"), 66, 1, 2, anonBlockName, 10, pt0, 41, 1.0, 42, 1.0, 43, 1.0, 50, 0.0, 0 ); if (entlist == NULL) return RTERROR; if ((status = acdbEntMake(entlist)) != RTNORM) { acutRelRb(entlist); return status; } acutRelRb(entlist); entlist = acutBuildList( RTDXF0, _T("ATTRIB"), 100, _T("AcDbEntity"), 8, _T("0"), 100, _T("AcDbText"), // 10, pt0, 40, 0.16, 1, _T("N23"), 50, 0.0, 41, 1.0, 51, 0.0, 7, _T("STANDARD"), 100, _T("AcDbAttribute"), 2, _T("NAME"), 72, 4, 74, 4, 11, pt0, 0); if (entlist == NULL) return RTERROR; if ((status = acdbEntMake(entlist)) != RTNORM) { acutRelRb(entlist); return status; } acutRelRb(entlist); entlist = acutBuildList( RTDXF0, _T("SEQEND"), 100, _T("AcDbEntity"), 8, _T("0"), 0 ); if (entlist == NULL) return RTERROR; if ((status = acdbEntMake(entlist)) != RTNORM) { acutRelRb(entlist); return status; } acutRelRb(entlist); return status; }
What exactly do you mean by "the program fails"?
Some thoughts:
1) Do you really need an AcDbAttributeDefinition?
2) You probably need to specify an owner for the AcDbAttribute
3) This entire exercise would be much cleaner if you used standard ObjectARX instead of the old ADS functions
@owenwengerd wrote:
What exactly do you mean by "the program fails"?
entlist = acutBuildList(RTDXF0, _T("ATTRIB"),100, _T( "AcDbEntity"),
8, _T("0"),
100, _T("AcDbText"),
// 10, pt0,
40, 0.16,
1, _T("N23"),
50, 0.0,
41, 1.0,
51, 0.0,
7, _T("STANDARD"),
100, _T("AcDbAttribute"),
2, _T("NAME"),
72, 4,
74, 4,
11, pt0,
0);
if (entlist == NULL)
returnRTERROR;
// here i get -5003 error value
if ((status = acdbEntMake(entlist)) != RTNORM)
{
acutRelRb(entlist);
returnstatus;
}
it looks like autocad doesn't like what is send in the above acdbEntMake() and i dot know what it is?
1) Do you really need an AcDbAttributeDefinition?
what do you mean by that? can i drop it?
2) You probably need to specify an owner for the AcDbAttribute
how this is done with ads?
3) This entire exercise would be much cleaner if you used standard ObjectARX instead of the old ADS functions
i need to create a quick anonymous attribute block to see if there are limitation on manipulate\editing it
so i can decide if i can use it in my current program and i though that ADS is much quicker
(no need to open & closing objects and error checking) my final anonymous block will have at least four attributes.
Moshe
Owen,
i would like to inform you that i did moved this to standard ObjectARX today
and it works like a charm
thank you very much for your help
Moshe