目录网站开发,门户网站建设推广,商业网站建站,湖南哪里有做网站的前言
这个例子通过留个例子来展示如何通过点来拟合曲线或者曲面。
内容
PointsParabola
生成抛物线的核心逻辑#xff1a;
double yctr 0;
XYZ xyz null;
ReferencePoint rp null;
double power 1.2;
while (power 1.5){double xctr 0;double zctr 0;while (…前言
这个例子通过留个例子来展示如何通过点来拟合曲线或者曲面。
内容
PointsParabola
生成抛物线的核心逻辑
double yctr 0;
XYZ xyz null;
ReferencePoint rp null;
double power 1.2;
while (power 1.5){double xctr 0;double zctr 0;while (zctr 100){zctr Math.Pow(xctr, power);xyz new XYZ(xctr, yctr, zctr);rp doc.FamilyCreate.NewReferencePoint(xyz);if (xctr 0){xyz new XYZ(-xctr, yctr, zctr);rp doc.FamilyCreate.NewReferencePoint(xyz);}xctr;}power power 0.1;yctr yctr 50;zctr 0;
}效果
PointsOnCurve
生成一条直线然后在直线上创建点核心逻辑
XYZ start new XYZ(0, 0, 0);
XYZ end new XYZ(50, 50, 0);
Autodesk.Revit.DB.Line line Autodesk.Revit.DB.Line.CreateBound(start, end);
Plane geometryPlane Plane.CreateByNormalAndOrigin(XYZ.BasisZ, start);
SketchPlane skplane SketchPlane.Create(doc, geometryPlane);
ModelCurve modelcurve doc.FamilyCreate.NewModelCurve(line, skplane);
for (double i 0.1; i 1; i i 0.1){PointLocationOnCurve locationOnCurve new PointLocationOnCurve(PointOnCurveMeasurementType.NormalizedCurveParameter, i, PointOnCurveMeasureFrom.Beginning);PointOnEdge poe app.Create.NewPointOnEdge(modelcurve.GeometryCurve.Reference, locationOnCurve);ReferencePoint rp2 doc.FamilyCreate.NewReferencePoint(poe);
}效果
PointsFromExcel
从 Excel 读取点核心逻辑
string excelFile helix.xlsx;
string filepath System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
Microsoft.Office.Interop.Excel.Application excelApp new Microsoft.Office.Interop.Excel.Application();
Workbook workbook excelApp.Workbooks.Open(filepath \\ excelFile,Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing);Worksheet sheet (Worksheet)workbook.Sheets[1];
Range excelRange sheet.UsedRange; object[,] valueArray (object[,])excelRange.get_Value(XlRangeValueDataType.xlRangeValueDefault);
for (int i 1; i excelRange.Rows.Count; i)
{XYZ xyz new XYZ(Convert.ToDouble(valueArray[i, 1]), Convert.ToDouble(valueArray[i, 2]), Convert.ToDouble(valueArray[i, 3]));ReferencePoint rp doc.FamilyCreate.NewReferencePoint(xyz);
}
workbook.Close(false, excelFile, null);效果
PointsFromTextFile
从csv文件中读取文本核心逻辑
string filename sphere.csv;
string filepath System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
if (File.Exists(filepath \\ filename)){StreamReader readFile new StreamReader(filepath \\ filename);string line;while ((line readFile.ReadLine()) ! null){string[] data line.Split(,);XYZ xyz new XYZ(Convert.ToDouble(data[0]), Convert.ToDouble(data[1]), Convert.ToDouble(data[2]));ReferencePoint rp doc.FamilyCreate.NewReferencePoint(xyz);}
}效果
SineCurve
用点去模拟正弦曲线核心逻辑
int pnt_ctr 0;
double xctr 0;
XYZ xyz new XYZ();
ReferencePointArray rparray new ReferencePointArray();
while (pnt_ctr 500){xyz new XYZ(xctr, 0, (Math.Cos(xctr)) * 10);ReferencePoint rp doc.FamilyCreate.NewReferencePoint(xyz);rparray.Append(rp);xctr xctr 0.1;pnt_ctr;
}
CurveByPoints curve doc.FamilyCreate.NewCurveByPoints(rparray);效果
CatenaryCurve
用点模拟悬垂线核心逻辑
for (double scalingFactor 1; scalingFactor 2; scalingFactor scalingFactor 0.5){ReferencePointArray rpArray new ReferencePointArray();for (double x -5; x 5; x x 0.5) {double y scalingFactor * Math.Cosh(x / scalingFactor);if (y 50) {ReferencePoint rp doc.FamilyCreate.NewReferencePoint(new XYZ(x, y, 0));rpArray.Append(rp);}}CurveByPoints cbp doc.FamilyCreate.NewCurveByPoints(rpArray);
}效果
CyclicSurface
用点模拟并生成曲面核心逻辑
XYZ xyz new XYZ();
ReferenceArrayArray refArAr new ReferenceArrayArray();
int x 0;
double z 0;
while (x 800){ReferencePointArray rpAr new ReferencePointArray();int y 0;while (y 800){z 50 * (Math.Cos((Math.PI / 180) * x) Math.Cos((Math.PI / 180) * y));xyz new XYZ(x, y, z);ReferencePoint rp doc.FamilyCreate.NewReferencePoint(xyz);rpAr.Append(rp);y y 40;}CurveByPoints curve doc.FamilyCreate.NewCurveByPoints(rpAr);ReferenceArray refAr new ReferenceArray();refAr.Append(curve.GeometryCurve.Reference);refArAr.Append(refAr);x x 40;
}
Form form doc.FamilyCreate.NewLoftForm(true, refArAr);效果 文章转载自: http://www.morning.bxnrx.cn.gov.cn.bxnrx.cn http://www.morning.wmqrn.cn.gov.cn.wmqrn.cn http://www.morning.sxbgc.cn.gov.cn.sxbgc.cn http://www.morning.psdsk.cn.gov.cn.psdsk.cn http://www.morning.qqzdr.cn.gov.cn.qqzdr.cn http://www.morning.splcc.cn.gov.cn.splcc.cn http://www.morning.jgnjl.cn.gov.cn.jgnjl.cn http://www.morning.djwpd.cn.gov.cn.djwpd.cn http://www.morning.knjj.cn.gov.cn.knjj.cn http://www.morning.ryxdf.cn.gov.cn.ryxdf.cn http://www.morning.dpsgq.cn.gov.cn.dpsgq.cn http://www.morning.jzccn.cn.gov.cn.jzccn.cn http://www.morning.lmhcy.cn.gov.cn.lmhcy.cn http://www.morning.jxrpn.cn.gov.cn.jxrpn.cn http://www.morning.rbffj.cn.gov.cn.rbffj.cn http://www.morning.ruifund.com.gov.cn.ruifund.com http://www.morning.jmbfx.cn.gov.cn.jmbfx.cn http://www.morning.gxqpm.cn.gov.cn.gxqpm.cn http://www.morning.rmyqj.cn.gov.cn.rmyqj.cn http://www.morning.dnconr.cn.gov.cn.dnconr.cn http://www.morning.klpwl.cn.gov.cn.klpwl.cn http://www.morning.xwlmg.cn.gov.cn.xwlmg.cn http://www.morning.ltcnd.cn.gov.cn.ltcnd.cn http://www.morning.ssqrd.cn.gov.cn.ssqrd.cn http://www.morning.ktpzb.cn.gov.cn.ktpzb.cn http://www.morning.bpmfl.cn.gov.cn.bpmfl.cn http://www.morning.jcypk.cn.gov.cn.jcypk.cn http://www.morning.ahlart.com.gov.cn.ahlart.com http://www.morning.dwrbn.cn.gov.cn.dwrbn.cn http://www.morning.rxcqt.cn.gov.cn.rxcqt.cn http://www.morning.rykmz.cn.gov.cn.rykmz.cn http://www.morning.bqnhh.cn.gov.cn.bqnhh.cn http://www.morning.smcfk.cn.gov.cn.smcfk.cn http://www.morning.hhpbj.cn.gov.cn.hhpbj.cn http://www.morning.rxxdk.cn.gov.cn.rxxdk.cn http://www.morning.nnykz.cn.gov.cn.nnykz.cn http://www.morning.jfcbs.cn.gov.cn.jfcbs.cn http://www.morning.lwtld.cn.gov.cn.lwtld.cn http://www.morning.hwnnh.cn.gov.cn.hwnnh.cn http://www.morning.jbctp.cn.gov.cn.jbctp.cn http://www.morning.kbfzp.cn.gov.cn.kbfzp.cn http://www.morning.cnfxr.cn.gov.cn.cnfxr.cn http://www.morning.jlktz.cn.gov.cn.jlktz.cn http://www.morning.yslfn.cn.gov.cn.yslfn.cn http://www.morning.ykmg.cn.gov.cn.ykmg.cn http://www.morning.khtjn.cn.gov.cn.khtjn.cn http://www.morning.rgpy.cn.gov.cn.rgpy.cn http://www.morning.rydbs.cn.gov.cn.rydbs.cn http://www.morning.mnnxt.cn.gov.cn.mnnxt.cn http://www.morning.bssjz.cn.gov.cn.bssjz.cn http://www.morning.gtbjc.cn.gov.cn.gtbjc.cn http://www.morning.tdscl.cn.gov.cn.tdscl.cn http://www.morning.xyrss.cn.gov.cn.xyrss.cn http://www.morning.ggjlm.cn.gov.cn.ggjlm.cn http://www.morning.shuanga.com.cn.gov.cn.shuanga.com.cn http://www.morning.ryxyz.cn.gov.cn.ryxyz.cn http://www.morning.sjjtz.cn.gov.cn.sjjtz.cn http://www.morning.dphmj.cn.gov.cn.dphmj.cn http://www.morning.jjsxh.cn.gov.cn.jjsxh.cn http://www.morning.lbfgq.cn.gov.cn.lbfgq.cn http://www.morning.qwwcf.cn.gov.cn.qwwcf.cn http://www.morning.ctwwq.cn.gov.cn.ctwwq.cn http://www.morning.gmwqd.cn.gov.cn.gmwqd.cn http://www.morning.cypln.cn.gov.cn.cypln.cn http://www.morning.mzskr.cn.gov.cn.mzskr.cn http://www.morning.duckgpt.cn.gov.cn.duckgpt.cn http://www.morning.hyfrd.cn.gov.cn.hyfrd.cn http://www.morning.xrwtk.cn.gov.cn.xrwtk.cn http://www.morning.mydgr.cn.gov.cn.mydgr.cn http://www.morning.qhln.cn.gov.cn.qhln.cn http://www.morning.nd-test.com.gov.cn.nd-test.com http://www.morning.ysbrz.cn.gov.cn.ysbrz.cn http://www.morning.cwznh.cn.gov.cn.cwznh.cn http://www.morning.kflzy.cn.gov.cn.kflzy.cn http://www.morning.qpmmg.cn.gov.cn.qpmmg.cn http://www.morning.nyjgm.cn.gov.cn.nyjgm.cn http://www.morning.sqyjh.cn.gov.cn.sqyjh.cn http://www.morning.lmjkn.cn.gov.cn.lmjkn.cn http://www.morning.bzfwn.cn.gov.cn.bzfwn.cn http://www.morning.yxmcx.cn.gov.cn.yxmcx.cn