[MSCE]关于图案填充的问题

在利用IAreaFillPropertiesEdit进行图案填充的时候,哪个方法可以进行图案填充定义及填充图案选择呢?

查找了PatternParams Struct当中的方法,好像没有找到对应函数。

Auto CAD中的填充图案能否一并选择来使用?

  • 其实offset这个值是否需要转换没有想的很清楚。符工,我后来重新从头看了一下,应该是找到原因了。在设置Pattern中数据行数的时候,起初我是用了GetDwgHatchDef()方法进行设置,但这个应是错误的,后来先设置好DwgHatchDef,然后利用SetDwgHatchDef()方法实现了正确填充。应该是这个原因吧。

  • 可否分享你最终调试通过的代码?这一块我也没有实际编程测试。



  • 符工,您好,代码如下,如果仍存在其他问题,敬请指正。

    void SetPatternFill(EditElementHandleR eeh)
    {
    	IAreaFillPropertiesEdit* fillEditP = dynamic_cast<IAreaFillPropertiesEdit *>(&eeh.GetHandler());
    	if (NULL == fillEditP)
    		return;
    	fillEditP->SetAreaType(eeh, false);
    	PatternParamsPtr params = PatternParams::Create();
    	params->SetModifiers(PatternParamsModifierFlags::DwgHatchDef);
    	params->SetScale(1.0);
    	params->SetTolerance(0.0);
    	DwgHatchDef dwgHatchDef;
    	dwgHatchDef.islandStyle = 0;
    	dwgHatchDef.nDefLines = 13;
    	dwgHatchDef.pixelSize = 0.0;
    	params->SetDwgHatchDef(dwgHatchDef);
    
    	bvector<DwgHatchDefLine>hatchDefLine;
    	DwgHatchDefLine hatchDefLineBase;
    	hatchDefLineBase.angle = 0.872665;
    	hatchDefLineBase.through = { 0.0, 0.0 };
    	hatchDefLineBase.offset = { 7.172602, -0.627521 };
    	hatchDefLineBase.nDashes = 2;
    	hatchDefLineBase.dashes[0] = 0.75;
    	hatchDefLineBase.dashes[1] = -8.25;
    	hatchDefLine.push_back(hatchDefLineBase);
    
    	hatchDefLineBase.angle = 6.195919;
    	hatchDefLineBase.through = { 0.0, 0.0 };
    	hatchDefLineBase.offset = { -1.387513, 7.521921 };
    	hatchDefLineBase.nDashes = 2;
    	hatchDefLineBase.dashes[0] = 0.60;
    	hatchDefLineBase.dashes[1] = -6.6;
    	hatchDefLine.push_back(hatchDefLineBase);
    
    	hatchDefLineBase.angle = 1.753208;
    	hatchDefLineBase.through = { 0.597717, -0.052293 };
    	hatchDefLineBase.offset = { 5.785088, 6.894400 };
    	hatchDefLineBase.nDashes = 2;
    	hatchDefLineBase.dashes[0] = 0.637402;
    	hatchDefLineBase.dashes[1] = -7.011421;
    	hatchDefLine.push_back(hatchDefLineBase);
    
    	hatchDefLineBase.angle = 0.806066;
    	hatchDefLineBase.through = { 0.0, 2.0 };
    	hatchDefLineBase.offset = { 10.672413, -1.655193 };
    	hatchDefLineBase.nDashes = 2;
    	hatchDefLineBase.dashes[0] = 1.125;
    	hatchDefLineBase.dashes[1] = -12.375;
    	hatchDefLine.push_back(hatchDefLineBase);
    
    	hatchDefLineBase.angle = 1.686610;
    	hatchDefLineBase.through = { 0.889367, 1.862067 };
    	hatchDefLineBase.offset = { 9.346619, 9.741186 };
    	hatchDefLineBase.nDashes = 2;
    	hatchDefLineBase.dashes[0] = 0.956103;
    	hatchDefLineBase.dashes[1] = -10.517138;
    	hatchDefLine.push_back(hatchDefLineBase);
    
    	hatchDefLineBase.angle = 6.129320;
    	hatchDefLineBase.through = { 0.0, 2.0 };
    	hatchDefLineBase.offset = { 9.346619, 9.741186 };
    	hatchDefLineBase.nDashes = 2;
    	hatchDefLineBase.dashes[0] = 0.9;
    	hatchDefLineBase.dashes[1] = -9.9;
    	hatchDefLine.push_back(hatchDefLineBase);
    
    	hatchDefLineBase.angle = 0.366519;
    	hatchDefLineBase.through = { 1.0, 1.5 };
    	hatchDefLineBase.offset = { 5.969071, -4.026189 };
    	hatchDefLineBase.nDashes = 2;
    	hatchDefLineBase.dashes[0] = 0.75;
    	hatchDefLineBase.dashes[1] = -8.25;
    	hatchDefLine.push_back(hatchDefLineBase);
    
    	hatchDefLineBase.angle = 5.689773;
    	hatchDefLineBase.through = { 1.0, 1.5 };
    	hatchDefLineBase.offset = { 2.433153, 7.251500 };
    	hatchDefLineBase.nDashes = 2;
    	hatchDefLineBase.dashes[0] = 0.60;
    	hatchDefLineBase.dashes[1] = -6.6;
    	hatchDefLine.push_back(hatchDefLineBase);
    
    	hatchDefLineBase.angle = 1.247063;
    	hatchDefLineBase.through = { 1.497423, 1.164484 };
    	hatchDefLineBase.offset = { 8.402224, 3.225312 };
    	hatchDefLineBase.nDashes = 2;
    	hatchDefLineBase.dashes[0] = 0.637402;
    	hatchDefLineBase.dashes[1] = -7.011421;
    	hatchDefLine.push_back(hatchDefLineBase);
    
    	hatchDefLineBase.angle = 0.654498;
    	hatchDefLineBase.through = { 0.0, 0.0 };
    	hatchDefLineBase.offset = { 0.121599, 3.328939 };
    	hatchDefLineBase.nDashes = 6;
    	hatchDefLineBase.dashes[0] = 0.0;
    	hatchDefLineBase.dashes[1] = -6.52;
    	hatchDefLineBase.dashes[2] = 0.0;
    	hatchDefLineBase.dashes[3] = -6.7;
    	hatchDefLineBase.dashes[4] = 0.0;
    	hatchDefLineBase.dashes[5] = -6.625;
    	hatchDefLine.push_back(hatchDefLineBase);
    
    	hatchDefLineBase.angle = 0.1309;
    	hatchDefLineBase.through = { 0.0, 0.0 };
    	hatchDefLineBase.offset = { 2.630695, 3.944117 };
    	hatchDefLineBase.nDashes = 6;
    	hatchDefLineBase.dashes[0] = 0.0;
    	hatchDefLineBase.dashes[1] = -3.82;
    	hatchDefLineBase.dashes[2] = 0.0;
    	hatchDefLineBase.dashes[3] = -6.37;
    	hatchDefLineBase.dashes[4] = 0.0;
    	hatchDefLineBase.dashes[5] = -2.525;
    	hatchDefLine.push_back(hatchDefLineBase);
    
    	hatchDefLineBase.angle = -0.567232;
    	hatchDefLineBase.through = { -2.23, 0.0 };
    	hatchDefLineBase.offset = { 5.338224, -0.225549 };
    	hatchDefLineBase.nDashes = 6;
    	hatchDefLineBase.dashes[0] = 0.0;
    	hatchDefLineBase.dashes[1] = -2.5;
    	hatchDefLineBase.dashes[2] = 0.0;
    	hatchDefLineBase.dashes[3] = -7.8;
    	hatchDefLineBase.dashes[4] = 0.0;
    	hatchDefLineBase.dashes[5] = -10.35;
    	hatchDefLine.push_back(hatchDefLineBase);
    
    	hatchDefLineBase.angle = -0.741765;
    	hatchDefLineBase.through = { -3.23, 0.0 };
    	hatchDefLineBase.offset = { 5.831862, 1.00105 };
    	hatchDefLineBase.nDashes = 6;
    	hatchDefLineBase.dashes[0] = 0;
    	hatchDefLineBase.dashes[1] = -3.25;
    	hatchDefLineBase.dashes[2] = 0;
    	hatchDefLineBase.dashes[3] = -5.18;
    	hatchDefLineBase.dashes[4] = 0;
    	hatchDefLineBase.dashes[5] = -7.35;
    	hatchDefLine.push_back(hatchDefLineBase);
    	fillEditP->AddPattern(eeh, *params, &hatchDefLine[0]);
    }

    Answer Verified By: Yongan.Fu 

  • 符老师   不知道您看出了  .pat文件中  offset  怎么转化成本特利的offset没有     以及ndashes的值对应.pat哪个值(这个突然知道了  是dashes的个数)   请指教