Can someone help me solve this? I am trying to return a result buffer of points to use in selecting some lines. The compiler errors are:
>Link:
1> Creating library C:\Documents and Settings\Ralph Gaston\My Documents\Visual Studio 2010\Projects\Headers\Win32\/Headers.lib and object C:\Documents and Settings\Ralph Gaston\My Documents\Visual Studio 2010\Projects\Headers\Win32\/Headers.exp
1>Headers_Utility.obj : error LNK2019: unresolved external symbol "class AcGePoint3d __cdecl GetMidPoint(class AcDbLine *)" (?GetMidPoint@@YA?AVAcGePoint3d@@PAVAcDbLine@@@Z) referenced in function "struct resbuf * __cdecl GetWindowPoints(class AcDbObjectId,class AcDbObjectId)" (?GetWindowPoints@@YAPAUresbuf@@VAcDbObjectId@@0@Z)
1>C:\Documents and Settings\Ralph Gaston\My Documents\Visual Studio 2010\Projects\Headers\Win32\/MLAWHeaders.arx : fatal error LNK1120: 1 unresolved externals
function and code that uses it:
/return the points to use for a crossing window between 2 parallel lines. //the 4 points will be inset 1 unit to the inside, and 6 units offset from //a line connecting the midpoints of the lines. struct resbuf *GetWindowPoints(AcDbObjectId Line1Id, AcDbObjectId Line2Id) { AcDbLine *pLine1; acdbOpenObject(pLine1, Line1Id, AcDb::kForRead); //get line points AcGePoint3d sp1 = pLine1->startPoint(); AcGePoint3d ep1 = pLine1->endPoint(); AcGePoint3d mid1 = GetMidPoint(pLine1); pLine1->close(); AcDbLine *pLine2; acdbOpenObject(pLine2, Line2Id, AcDb::kForRead); AcGePoint3d sp2 = pLine2->startPoint(); AcGePoint3d ep2 = pLine2->endPoint(); AcGePoint3d mid2 = GetMidPoint(pLine2); pLine2->close(); //get the unit vector from the midpoint of 1 to the midpoint of 2 AcGeVector3d VecMid1_Mid2; VecMid1_Mid2.x = mid2.x - mid1.x; VecMid1_Mid2.y = mid2.y - mid1.y; VecMid1_Mid2.z = mid2.z - mid1.z; VecMid1_Mid2 = VecMid1_Mid2.normalize(); //get the unit vector in the direction of line1 AcGeVector3d VecSp1_Ep1; VecSp1_Ep1.x = ep1.x - sp1.x; VecSp1_Ep1.y = ep1.y - sp1.y; VecSp1_Ep1.z = ep1.z - sp1.z; VecSp1_Ep1 = VecSp1_Ep1.normalize(); //using line1's midpoint, add vectors to get 1 unit toward //line 2 and 6 units perpendicular to midpoint vector (each side) double OffsetOutDist = 6; double InsetDist = 1; AcGePoint3d pt1 = mid1 + InsetDist * VecMid1_Mid2 + OffsetOutDist * VecSp1_Ep1; AcGePoint3d pt2 = mid1 + InsetDist * VecMid1_Mid2 - OffsetOutDist * VecSp1_Ep1; //now using line2's midpoint, do it again. Points must be obtained //in order to get a box instead of an x AcGePoint3d pt3 = mid2 - InsetDist * VecMid1_Mid2 - OffsetOutDist * VecSp1_Ep1; AcGePoint3d pt4 = mid2 - InsetDist * VecMid1_Mid2 + OffsetOutDist * VecSp1_Ep1; //organize the points into a result buffer ads_point adsPt1, adsPt2, adsPt3, adsPt4; adsPt1[X] = pt1.x; adsPt1[Y] = pt1.y; adsPt1[Z] = pt1.z; adsPt2[X] = pt2.x; adsPt2[Y] = pt2.y; adsPt2[Z] = pt2.z; adsPt3[X] = pt3.x; adsPt3[Y] = pt3.y; adsPt3[Z] = pt3.z; adsPt4[X] = pt4.x; adsPt4[Y] = pt4.y; adsPt4[Z] = pt4.z; struct resbuf *rbPointList; rbPointList = acutBuildList(RTPOINT, adsPt1, RTPOINT, adsPt2, RTPOINT, adsPt3, RTPOINT, adsPt4, RTNONE); return rbPointList; } struct resbuf *GetWindowPoints(AcDbObjectId Line1Id, AcDbObjectId Line2Id); struct resbuf *rbPointlist; rbPointlist = GetWindowPoints(JambLine1Id, JambLine2Id); ads_name WallsInOpenings; if(!WallSelSetFromPoints(WallsInOpenings, rbPointlist))
Thanks,
Ralph Gaston
AcGePoint3d mid1 = GetMidPoint(pLine1);
Where the function GetMidPoint is defined?
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
I ended up getting this to work at some point with several changes made. I believe the most important was that I added the function above the main file, instead of calling it from a separate cpp file. I wish I didn't have to do that, but as long as it works...
The GetMidPoint function I called was very similar to this, except now it asks for an ObjectId instead of a pointer - similar to some of the example code I read that came with the documentation.
//return the midpoint of a AcDbLine as an AcGePoint3d value AcGePoint3d GetMidPoint(AcDbObjectId LineObjectId) { AcGePoint3d sp, ep, MidPoint; //cast the pointer-to-line to a pointer-to-entity so it will fit in the open function AcDbLine *pLine; acdbOpenAcDbEntity((AcDbEntity*&)pLine, LineObjectId, AcDb::kForRead); //get the start and end points of the line sp = pLine->startPoint(); ep = pLine->endPoint(); //get the midpoint as the average of each direction MidPoint.x = (sp.x + ep.x)/2; MidPoint.y = (sp.y + ep.y)/2; MidPoint.z = (sp.z + ep.z)/2; pLine->close(); return MidPoint; }
Thanks,
rg
An improved version of your function just for the heck of it:
//return the midpoint of a AcDbLine as an AcGePoint3d value AcGePoint3d GetMidPoint(const AcDbObjectId& idLine) { AcGePoint3d ptMid; AcDbLine *pLine; if (Acad::eOk == acdbOpenObject(pLine, idLine, AcDb::kForRead)) { AcGePoint3d ptStart = pLine->startPoint(); AcGePoint3d ptEnd = pLine->endPoint(); pLine->close(); ptMid.x = (ptStart.x + ptEnd.x) / 2.0; ptMid.y = (ptStart.y + ptEnd.y) / 2.0; ptMid.z = (ptStart.z + ptEnd.z) / 2.0; } return ptMid; }
Wow. I just started, but I don't know how many places I am opening, then checking to make sure it is the right type, then casting to another variable of that type. This will really simplify a lot of work. Thanks again Owen.
Thanks,
Ralph Gaston
Can't find what you're looking for? Ask the community or share your knowledge.