AcDbLinetypeTable* pLinetypeTable=NULL;
		Acad::ErrorStatus es = acdbHostApplicationServices()->workingDatabase()->getLinetypeTable(pLinetypeTable,AcDb::kForWrite);
		if (Acad::eOk != es)
		{
			return;
		}
		AcDbObjectId txtStyleId=acdbHostApplicationServices()->workingDatabase()->textstyle();
		AcDbLinetypeTableRecord *pLinetypeTableRec=new AcDbLinetypeTableRecord;
		//设置线型名称注意,命名规范
		pLinetypeTableRec->setName(L"YJV10X5");
		//pLinetypeTableRec->setAsciiDescription(_T("YJV10X5 ____YJV10*5 ____"));
		//线型说明文字高版本建议用setComments
		pLinetypeTableRec->setComments(_T("YJV10X5 ____YJV10*5 ____"));
		//设置Dash短划线数量
		pLinetypeTableRec->setNumDashes(3);
		//设置短划线的长度,正值为实线,负值为空格,0是点
		pLinetypeTableRec->setDashLengthAt(0,1.25);
		pLinetypeTableRec->setDashLengthAt(1,-1.75);

		//设置Shape或Text样式Id
		pLinetypeTableRec->setShapeStyleAt(1,txtStyleId);
		//比例,文字高度
		pLinetypeTableRec->setShapeScaleAt(1,0.25);
		//设置文字原点偏移位置
		pLinetypeTableRec->setShapeOffsetAt(1,AcGeVector2d(-1.55,-0.125));
		//设置文字索引位置和内容,索引≥0
		pLinetypeTableRec->setTextAt(1,_T("YJV10*5"));

		pLinetypeTableRec->setDashLengthAt(2,0.25);
		//设置自动缩放比例
		pLinetypeTableRec->setIsScaledToFit(0);
		//设置图案长度一般等于dashLength实际距离之和
		pLinetypeTableRec->setPatternLength(3.25);
		pLinetypeTable->add(pLinetypeTableRec);
		pLinetypeTableRec->close();
		pLinetypeTable->close();

  

  

附:关于自定义线型中的文字

02-13 17:54