📄 mfctempl.cpp
字号:
// (C) Copyright 1996,1997 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
// MFCTempl.cpp : Defines the initialization routines for the DLL.
//
// THE FOLLOWING CODE APPEARS IN THE SDK DOCUMENT.
#include "stdafx.h"
#include "MFCTempl.h"
#include "compublic.h"
#include "unitdesign.h"
typedef struct
{
int iNo;
double rKj;
} ZW;
CString strFileName, strMesage;
double rDeep, rDist, rR, rWidth;
int iDx;
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
extern "C" HWND adsw_acadMainWnd();
extern "C" HINSTANCE _hdllInstance;
static HWND hWndACAD = NULL;
extern "C" BOOL APIENTRY DllMain(HINSTANCE, DWORD, LPVOID);
BOOL GetRoadInf(ads_name ent, CString &strHandle, CString &strEndHandle,
double &rStartZH, double &rEndZH);
BOOL GetInfFromZH(CString strHeadHandle, double rZh, double &xx, double &yy, double &a);
int CStrToFJ(CString strSource, CStringArray *rData, CString sc);
double CovStrToZH(CString str, double rSTartST, CArray <double, double> &bnn);
void InitMFC()
{
DllMain(_hdllInstance, DLL_PROCESS_ATTACH, NULL);
hWndACAD = /* GetActiveWindow() */ adsw_acadMainWnd();
strFileName = _T("");
strMesage = _T("");
rDeep = 0.0;
rDist = 0.0;
rR = 0.0;
rWidth = 0.0;
iDx = 0;
MakeNewLayer("桥墩位", 3, "acad.lin", "CONTINIUS");
}
void EndMFC()
{
DllMain(_hdllInstance, DLL_PROCESS_DETACH, NULL);
}
//由桩号获取信息
BOOL GetInfFromZH(CString strHeadHandle, double rZh, double &xx, double &yy, double &a)
{
int iType, iTurn;
double rSTartZH = 0.0, rEndZH = 0.0;
AcDbObject *pObj;
ads_name ent;
AcDbObjectId entId;
struct resbuf *pRb = NULL, *pRbCur = NULL;
char strHandle[20], strNextHandle[20], strBackHandle[20];
double rStartR, rEndR, rR, rA, rLen, rStartFWJ, rCalLen, rStartX, rStartY,rTep;
ads_point pt, ptStart;
LineUnit line;
CircleUnit circle;
AllayUnit allay;
ads_point ptt;
ads_handent(strHeadHandle, ent);
while(TRUE)
{
//获取当前实体类型
GetEntType(ent, &iType);
if (Acad::eOk != acdbGetObjectId(entId, ent))
{
ads_relrb(pRb);
return FALSE;
}
if (Acad::eOk != acdbOpenObject(pObj, entId, AcDb::kForRead))
{
ads_relrb(pRb);
return FALSE;
}
pRb = pObj->xData("LHB_YJ");
pRbCur = pRb;
if (NULL == pRb)
{
pObj->close();
ads_relrb(pRb);
return FALSE;
}
pObj->close();
//获取当前设计单元句柄及下一个单元句柄
strcpy(strHandle, rbSeek(pRb, 1000)->resval.rstring);
pRb = rbSeek(pRb, 1000)->rbnext;
strcpy(strNextHandle,rbSeek(pRb, 1000)->resval.rstring);
switch(iType)
{
case 1:
rSTartZH = rbSeek(pRb, 1040)->resval.rreal;
rEndZH = rbSeek(pRb, 1040)->rbnext->resval.rreal;
break;
case 2:
rSTartZH = rbSeek(pRb, 1040)->resval.rreal;
rEndZH = rbSeek(pRb, 1040)->rbnext->resval.rreal;
break;
case 3:
rSTartZH = rbSeek(pRb, 1041)->resval.rreal;
for(int i = 0; i < 0; i++) pRb = rbSeek(pRb, 1041)->rbnext;
rSTartZH = rbSeek(pRb, 1041)->resval.rreal;
rEndZH = rbSeek(rbSeek(pRb, 1041), 1041)->resval.rreal;
break;
return FALSE;
}
if (rZh <= rEndZH) break;
else
{
ads_handent(strNextHandle, ent);
}
}
//由当前实体获取详细桩号坐标
rCalLen = rZh - rSTartZH;
rStartX = rbSeek(pRbCur, 1011)->resval.rpoint[0];
rStartY = rbSeek(pRbCur, 1011)->resval.rpoint[1];
rStartFWJ = line.ConvertFWJ(ads_angle(rbSeek(pRbCur, 1011)->resval.rpoint,
rbSeek(rbSeek(pRbCur, 1011), 1011)->resval.rpoint));
rLen = rbSeek(pRbCur, 1041)->resval.rreal;
switch(iType)
{
case 1: //直线单元
line.SetStartInf(rStartX, rStartY, rStartFWJ, rLen);
line.GetLenInf(rCalLen, xx, yy, a);
break;
case 2: //回旋线单元
rTep = circle.ConvertFWJ((pRbCur = rbSeek(pRbCur, 1011))->resval.rpoint,
(pRbCur = rbSeek(pRbCur, 1011))->resval.rpoint,
(pRbCur = rbSeek(pRbCur, 1011))->resval.rpoint,
(pRbCur = rbSeek(pRbCur, 1011))->resval.rpoint);
rR = rbSeek(rbSeek(pRbCur, 1041), 1041)->resval.rreal;
iTurn = (rTep > 0.0 ? -1: 1);
ads_printf("\n计算出:圆曲线单元-切向角%f", rTep);
circle.SetStartInf(rStartX, rStartY, fabs(rStartFWJ), iTurn, rLen, rR);
circle.GetLenInf(rCalLen, xx, yy, a);
break;
case 3: //回旋线单元
rTep = allay.ConvertFWJ((pRbCur = rbSeek(pRbCur, 1011))->resval.rpoint,
(pRbCur = rbSeek(pRbCur, 1011))->resval.rpoint,
(pRbCur = rbSeek(pRbCur, 1011))->resval.rpoint,
(pRbCur = rbSeek(pRbCur, 1011))->resval.rpoint);
iTurn = (rTep > 0.0 ? -1: 1);
ads_printf("\n计算出:回旋线单元-切向角%f", rTep);
pRbCur = rbSeek(pRbCur, 1041);
pRbCur = pRbCur->rbnext;
rA = pRbCur->resval.rreal;
pRbCur = pRbCur->rbnext;
rStartR = pRbCur->resval.rreal;
pRbCur = pRbCur->rbnext;
rEndR = pRbCur->resval.rreal;
allay.SetStartInf(rStartX, rStartY, fabs(rStartFWJ), iTurn, rA, rStartR, rEndR);
allay.GetLenInf(rCalLen, xx, yy, a);
break;
return FALSE;
}
ads_relrb(pRbCur);
}
BOOL GetRoadInf(ads_name ent, CString &strHandle, CString &strEndHandle,
double &rStartZH, double &rEndZH)
{
int iType;
AcDbObject *pObj;
AcDbObjectId entId;
ads_point pt;
struct resbuf *pRb = NULL, *pRb1 = NULL;
char strTep[20], strTep1[20];
strcpy(strTep, "NODATA");
while(strcmp(strTep, "") == 1)
{
if (Acad::eOk != acdbGetObjectId(entId, ent))
{
ads_relrb(pRb);
return FALSE;
}
if (Acad::eOk != acdbOpenObject(pObj, entId, AcDb::kForRead))
{
ads_relrb(pRb);
return FALSE;
}
strcpy(strTep1, GetIdHandle(entId));
pRb = pObj->xData("LHB_YJ");
pObj->close();
if (NULL == pRb)
{
pObj->close();
ads_relrb(pRb);
return FALSE;
}
strcpy(strTep, rbSeek(rbSeek(pRb, 1000), 1000)->resval.rstring);
if (strcmp(strTep, "") == 1) ads_handent(strTep, ent);
}
//得出路线起始单元句柄
strHandle.Format("%s", strTep1);
ads_handent(strHandle, ent);
GetEntType(ent, &iType);
//获取当前实体类型
switch(iType)
{
case 1:
rStartZH = rbSeek(pRb, 1040)->resval.rreal;
break;
case 2:
rStartZH = rbSeek(pRb, 1040)->resval.rreal;
break;
case 3:
for(int i = 0; i < 2; i++) pRb = pRb->rbnext;
rStartZH = rbSeek(pRb, 1041)->resval.rreal;
break;
return FALSE;
}
ads_printf("\n查询路线起点桩号=%f ", rStartZH);
strcpy(strTep, "NODATA");
while(strcmp(strTep, "") == 1)
{
if (Acad::eOk != acdbGetObjectId(entId, ent))
{
ads_relrb(pRb1);
return FALSE;
}
if (Acad::eOk != acdbOpenObject(pObj, entId, AcDb::kForRead))
{
ads_relrb(pRb1);
return FALSE;
}
strcpy(strTep1, GetIdHandle(entId));
pRb1 = pObj->xData("LHB_YJ");
pObj->close();
if (NULL == pRb1)
{
pObj->close();
ads_relrb(pRb1);
return FALSE;
}
strcpy(strTep, rbSeek(rbSeek(rbSeek(pRb1, 1000),
1000), 1000)->resval.rstring);
if (strTep != "") ads_handent(strTep, ent);
}
//得出路线终止单元句柄
strEndHandle.Format("%s", strTep1);
ads_handent(strEndHandle, ent);
//获取当前实体类型
GetEntType(ent, &iType);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -