大侠哥哥们请帮忙 小妹快哭出来了
本帖最后由 作者 于 2004-11-3 11:11:53 编辑 <br /><br /> 我就想从文件里面读出x,y坐标,然后循环画点。可是我这样写根本画不出来。要是我把读文件那段函数写在drawplanestation()主程序里,在运行cad时,就说我犯了致命的错误。各位大哥快请帮帮小妹我吧!!<BR><BR>void initApp()<BR>{<BR> acedRegCmds->addCommand("drawplanestation_COMMAND",<BR> "planestation",<BR> "1",<BR> ACRX_CMD_TRANSPARENT,<BR> drawplanestation);<BR> <BR>}double xx,yy; <BR>int i=0;
<BR>void read_data()<BR>{<BR> FILE *fp;<BR> float px,py,pz;<BR> fp=fopen("planestation1.txt","wr");<BR> char x,y;<BR> while(!feof(fp))<BR> {<BR> if (fscanf(fp,"%s%s",x,y)==EOF)<BR> break;<BR> xx=atof(x);<BR> yy=atof(y);<BR> <BR> <BR> i=i+1; <BR> }<BR> fclose(fp);<BR> <BR>}
<BR>void drawplanestation()<BR>{ <BR> AcDbObjectIdArray idArray;<BR> float px,py,pz;<BR> read_data();<BR> <BR> for (i=0;i<293;i++)<BR> {<BR> px=xx;<BR> py=yy;<BR> pz=100;<BR> idArray.append(createPoint3D(px,py,pz));<BR> }<BR> <BR>}
<BR>AcDbObjectId createPoint3D(float l,float m,float n)<BR>{ AcGePoint3d p(l,m,n);<BR> AcDbPoint *po= new AcDbPoint(p);<BR> po->setColorIndex(3);<BR> AcDbBlockTable *pBlockTable;<BR> acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,AcDb::kForWrite);<BR> AcDbBlockTableRecord *pBlockTableRecord;<BR> pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);<BR> pBlockTable->close();<BR> AcDbObjectId pointId;<BR> pBlockTableRecord->appendAcDbEntity(pointId,po);<BR> po->close();<BR> pBlockTableRecord->close();<BR> return pointId;<BR> delete [] po;
}
void unloadApp()<BR>{<BR> acedRegCmds->removeGroup("drawplanestation_COMMAND");
}<BR>
回复
请把你的坐标文件也贴上来吧! 谢谢这位版主,以下是文件内容:左边是x坐标,右边是y坐标。7177.54 8975.06 <BR>6486.46 8558.98 <BR>7241.46 9244.35 <BR>6629.36 8323.66 <BR>6389.57 8720.73 <BR>6760.03 8492.40 <BR>7389.53 8635.84 <BR>6727.32 8934.57 <BR>6619.62 9107.85 <BR>6565.24 8842.17 <BR>6937.04 8588.78 <BR>7116.02 8268.71 <BR>7001.96 8866.86 <BR>6892.92 9047.06 <BR>7202.50 8533.59 <BR>7070.08 9141.08 <BR>7606.89 9023.53 <BR>7720.54 8836.88 <BR>7858.92 9382.80 <BR>7051.94 8780.26 <BR>7159.22 8604.76 <BR>7328.41 8712.71 <BR>7229.33 8876.16 <BR>7758.29 8387.43 <BR>7196.83 8836.67 <BR>7183.15 8859.02 <BR>7155.86 8904.78 <BR>7142.26 8924.19 <BR>7105.08 8988.20 <BR>7090.93 9009.62 <BR>7262.91 8820.55 <BR>7249.81 8841.22 <BR>7210.90 8909.16 <BR>7185.10 8953.83 <BR>7149.31 9010.20 <BR>7131.58 9033.99 <BR>7162.33 8696.37 <BR>7149.78 8716.47 <BR>7137.76 8736.38 <BR>7120.03 8759.59 <BR>7113.38 8781.51 <BR>7094.96 8805.77 <BR>7085.85 8828.52 <BR>7070.26 8850.24 <BR>7057.74 8871.39 <BR>7043.77 8895.25 <BR>7032.93 8914.90 <BR>7017.59 8934.95 <BR>7006.92 8953.83 <BR>6993.28 8978.11 <BR>7165.97 8789.69 <BR>7113.70 8877.26 <BR>7098.63 8897.51 <BR>7060.05 8961.23 <BR>7047.51 8982.30 <BR>7033.58 9005.29 <BR>7020.83 9025.35 <BR>7318.03 8828.10 <BR>7306.41 8846.38 <BR>7293.89 8866.23 <BR>7280.44 8889.27 <BR>7253.33 8930.19 <BR>7241.60 8948.74 <BR>7214.10 8998.73 <BR>7200.99 9019.56 <BR>7190.29 9038.70 <BR>7177.06 9059.38 <BR>7372.24 8831.67 <BR>7336.80 8894.66 <BR>7323.55 8913.47 <BR>7296.17 8956.02 <BR>7268.97 9001.35 <BR>7026.59 8734.44 <BR>7010.64 8755.21 <BR>6999.63 8774.87 <BR>6974.39 8817.50 <BR>6958.36 8841.87 <BR>6932.17 8885.10 <BR>6920.84 8905.81 <BR>6907.29 8925.11 <BR>7042.95 8803.90 <BR>7028.21 8825.49 <BR>7016.46 8846.10 <BR>6975.66 8910.56 <BR>7009.24 8573.57 <BR>6992.62 8596.37 <BR>6966.82 8638.96 <BR>6942.75 8680.25 <BR>6887.61 8767.15 <BR>7049.02 8601.49 <BR>7035.81 8623.73 <BR>7009.39 8665.22 <BR>6995.51 8686.72 <BR>6980.98 8708.59 <BR>6956.68 8750.58 <BR>6903.63 8835.45 <BR>6889.70 8857.43 <BR>6877.25 8878.00 <BR>6829.20 8671.60 <BR>6785.79 8735.76 <BR>6737.08 8819.96 <BR>6725.49 8842.20 <BR>6710.51 8862.40 <BR>6884.57 8679.04 <BR>6870.91 8697.00 <BR>6844.32 8740.41 <BR>6815.58 8784.26 <BR>6792.35 8825.10 <BR>6750.85 8892.88 <BR>6786.85 8645.16 <BR>6747.00 8707.91 <BR>6720.73 8751.80 <BR>6705.15 8769.94 <BR>6694.57 8797.80 <BR>6668.05 8836.16 <BR>6654.39 8856.88 <BR>7531.97 8373.88 <BR>7479.53 8458.38 <BR>7201.69 8922.78 <BR>7588.81 8290.85 <BR>7128.17 8059.51 <BR>7756.28 8972.54 <BR>7704.90 9059.80 <BR>7650.98 9135.73 <BR>7189.00 8746.34 <BR>7137.22 8831.31 <BR>7080.28 8923.83 <BR>7019.64 8057.93 <BR>6916.39 8229.38 <BR>6807.80 8403.62 <BR>6874.64 8316.65 <BR>6653.22 8649.26 <BR>6508.60 8910.55 <BR>7915.36 8958.11 <BR>7987.59 8764.88 <BR>7931.54 8852.21 <BR>7856.05 9018.64 <BR>7740.64 9187.92 <BR>7677.11 9286.01 <BR>6931.02 8012.21 <BR>6883.18 8090.82 <BR>6830.76 8177.18 <BR>6779.39 8262.66 <BR>6729.22 8347.38 <BR>6674.78 8434.74 <BR>6622.04 8521.46 <BR>6569.85 8605.29 <BR>6498.50 8700.99 <BR>6404.07 8784.82 <BR>6421.50 8874.77 <BR>6797.00 8040.56 <BR>6744.98 8125.10 <BR>6701.92 8216.77 <BR>6658.47 8274.72 <BR>6539.25 8471.05 <BR>6440.33 8627.68 <BR>6330.42 8812.30 <BR>6905.74 7869.93 <BR>8150.84 8869.44 <BR>8121.02 8952.74 <BR>8016.77 9121.10 <BR>7907.44 9288.44 <BR>7965.24 9216.54 <BR>7465.96 8678.80 <BR>7409.65 8758.64 <BR>7354.88 8857.09 <BR>7311.20 8936.34 <BR>7252.82 9025.87 <BR>6939.83 8951.64 <BR>7107.63 8692.76 <BR>7264.18 8443.96 <BR>7346.93 8292.08 <BR>7317.18 8355.59 <BR>7778.73 9098.82 <BR>7415.37 8179.79 <BR>8063.30 9045.40 <BR>7268.71 8787.37 <BR>6708.90 8587.88 <BR>7990.09 8401.68 <BR>7591.86 8664.37 <BR>7715.48 8480.86 <BR>7652.04 8561.84 <BR>7549.99 8730.31 <BR>7303.03 9159.09 <BR>7501.23 8815.36 <BR>7390.08 9002.59 <BR>7449.70 8894.49 <BR>7347.31 9062.01 <BR>7226.72 8298.19 <BR>7170.39 8383.91 <BR>7123.82 8465.23 <BR>7070.42 8557.39 <BR>7022.98 8640.64 <BR>6966.20 8728.04 <BR>6913.11 8811.98 <BR>6862.45 8904.93 <BR>6804.20 8996.26 <BR>6759.76 9073.73 <BR>7276.75 8213.25 <BR>7330.74 8126.05 <BR>7792.14 8524.44 <BR>7740.21 8611.09 <BR>7685.00 8689.73 <BR>7632.34 8783.02 <BR>7823.76 8673.90 <BR>7530.46 8955.63 <BR>7477.80 9036.83 <BR>7422.46 9124.72 <BR>7377.64 9206.17 <BR>7582.75 8866.20 <BR>7441.77 8533.05 <BR>7193.11 8163.88 <BR>7089.04 8330.19 <BR>6993.36 8506.79 <BR>6889.49 8666.24 <BR>6594.04 8802.04 <BR>6776.40 8853.68 <BR>6683.87 9025.04 <BR>6829.99 8761.60 <BR>7029.76 8434.31 <BR>7234.46 8089.97 <BR>7879.19 8573.93 <BR>7566.18 9083.46 <BR>7929.51 8488.66 <BR>7776.72 8740.90 <BR>7669.56 8916.35 <BR>7513.15 9177.65 <BR>7106.05 8111.89 <BR>7054.98 8196.68 <BR>7000.04 8289.00 <BR>6942.00 8372.45 <BR>6893.36 8455.60 <BR>6836.56 8532.65 <BR>6793.43 8623.79 <BR>6757.45 8692.25 <BR>6684.99 8811.99 <BR>6635.27 8898.98 <BR>6582.07 8981.41 <BR>6542.32 9054.80 <BR>6931.04 8692.59 <BR>6899.04 8741.82 <BR>6870.17 8793.61 <BR>6814.55 8691.86 <BR>6741.94 8807.84 <BR>6938.51 8766.45 <BR>6859.88 8707.46 <BR>6806.26 8801.40 <BR>6729.90 8743.15 <BR>6608.42 9166.49 <BR>6498.89 9078.27 <BR>6466.31 8946.23 <BR>6396.74 8919.14 <BR>6256.63 8831.46 <BR>6348.03 8693.01 <BR>6397.95 8598.04 <BR>6440.19 8537.13 <BR>6500.50 8437.57 <BR>6584.85 8295.16 <BR>6610.76 8251.91 <BR>6659.77 8183.20 <BR>6701.99 8105.15 <BR>6758.12 8013.92 <BR>6938.17 7725.47 <BR>6975.30 7982.87 <BR>7032.99 8009.13 <BR>7139.73 8015.45 <BR>7250.43 8040.48 <BR>7350.63 8081.69 <BR>7438.95 8135.45 <BR>7613.24 8247.96 <BR>7796.66 8357.16 <BR>7823.92 8444.51 <BR>8033.32 8306.06 <BR>8035.26 8742.03 <BR>8218.32 8855.05 <BR>8164.36 8975.97 <BR>8102.70 9075.44 <BR>8053.44 9151.07 <BR>8001.10 9241.14 <BR>7954.16 9321.72 <BR>7871.04 9450.25 <BR>7634.68 9320.75 <BR>7609.58 9201.69 <BR>7521.68 9226.93 <BR>7386.18 9253.02 <BR>7182.33 9315.87 <BR>7204.69 9083.62 <BR>6991.51 9276.94 <BR>7027.21 9078.35 <BR>6998.18 9085.89 <BR>6974.68 9051.50 <BR>6917.61 9096.88 <BR>6762.40 9121.97 <BR> 你单步调试试试看,数组有没有读对值? 在Arx框架下,我不会单步调试。我在mfc框架下调试过,可以读。
请问怎样设断点调试呀,在Arx框架下?一按执行就调出cad界面了。 double xx,yy;
重復定义两次!!
read_data()函数里面把外面的定义隐藏了!!
外面数据为空!!
for (i=0;i<293;i++)<BR> {<BR> px=xx;<BR> py=yy;<BR> pz=100;<BR> idArray.append(createPoint3D(px,py,pz));<BR> }<BR>执行时就出错了 easypower gg ;我把read_data()里面的xx,yy去掉了,还是画不出来。编译没有错,可就是在cad里不出现图。 delete [] po;去掉 power gg;还是 调试没有错,cad不出图,会不会是我的软件装得有问题?
要不在你的机器上先运行一下看看?
回复
参考:static void CreatePointFromTxtFile_cp(void)<BR> {<BR> // Add your code for command CreatePointFromTxtFile._cp here<BR> CFileFind finder;<BR> CString txtFile = "C:\\1.txt";<BR> if (finder.FindFile(txtFile) != TRUE)<BR> {<BR> acedAlert("txt文件不存在!");<BR> return;<BR> }<BR> CStdioFile dataStore;<BR> CString somecode;
BOOL bIsOk = dataStore.Open(txtFile, CFile::modeRead | CFile::shareDenyWrite | CFile::typeText);<BR> if (!bIsOk) return;
AcGePoint3dArray pointArray;<BR> AcGePoint3d pt;
while (dataStore.ReadString(somecode) != NULL)<BR> {<BR> somecode.TrimLeft(_T(" "));<BR> somecode.TrimRight(_T(" "));<BR> CString x;<BR> CString y;<BR> x = somecode.Left(somecode.Find(_T(" ")));<BR> y = somecode.Mid(somecode.Find(_T(" "))).Trim();<BR> //acedAlert(x);<BR> //acedAlert(y);<BR> pt.x = atof(x);<BR> pt.y = atof(y);<BR> pt.z = 0.0;<BR> pointArray.append(pt);<BR> }
for (int i = 0; i < pointArray.length(); i++)<BR> {<BR> pt.set(pointArray.x, pointArray.y, 0.0);
AcDbPoint* ptObj = new AcDbPoint;<BR> ptObj->setPosition(pt);<BR> AcDbBlockTable *pBlockTable;<BR> acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;<BR> pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);<BR> pBlockTable->close();
AcDbObjectId ptId;<BR> pBlockTableRecord->appendAcDbEntity(ptId, ptObj);
pBlockTableRecord->close();<BR> ptObj->close();<BR> }<BR> }
文本文件: "c:\\1.txt"
结果:
源程序:
页:
[1]
2