ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

curious problem about hatch display

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
421232206
769 Views, 2 Replies

curious problem about hatch display

I have two hatches, one is created from arx code, the other is drawed throuth cad's "hatch" command. both have the same scale property, but they display differently. look the picture below.Hatch_Scale_Problem.jpg

 

the code I use to insert the hatch is below:

AcDbObjectId DrawHatch(const AcDbObjectIdArray& loops,const TCHAR* szPattern,double dScale,const int nColorIndex,const double dElevation,const bool bAssociative,TCHAR *szCode,AcDbGroup *pGroup,TCHAR *szLayer,bool bCustom)
    {
        AcDbObjectId hatchID = AcDbObjectId::kNull;

        AcDbHatch* pHatch = new AcDbHatch();
        // Set hatch plane
        AcGeVector3d normal(0.0, 0.0, 1.0);
        pHatch->setNormal(normal);//目前先只支持平行于平面的Hatch。
        pHatch->setElevation(dElevation);
        // Set non associative hatch
        pHatch->setAssociative(bAssociative);
        // Set hatch pattern to SolidFill type
        if (!bCustom)
        {
            pHatch->setPattern(AcDbHatch::kPreDefined, szPattern);//目前只运行预定义的类型。
        }
        else
        {
            if (pHatch->setPattern(AcDbHatch::kCustomDefined,szPattern) != eOk)
            {
                acutPrintf(_T("\n填充样式名\"%s\"不存在,用样式\"angle\"代替生成。"),szPattern);
                pHatch->setPattern(AcDbHatch::kPreDefined, _T("angle"));
            }
        }
        
        // Set hatch style to kNormal
        pHatch->setHatchStyle(AcDbHatch::kNormal);

        pHatch->setPatternScale(dScale);
        int i=0;
        for (i=0;i<loops.length();i++)
        {
            AcDbObjectIdArray idArr;
            idArr.setPhysicalLength(1);
            idArr.append(loops[i]);
            pHatch->appendLoop(AcDbHatch::kDefault,idArr);/
       }


        pHatch->evaluateHatch();//这个函数用于计算
        if(AppendEntity(pHatch,hatchID) == false)
        {
            delete pHatch;
            return hatchID;
        }

        if (bAssociative)
        {
            // Get all associative source boundary object Ids for later use.
            //
            AcDbObjectIdArray dbObjIds;
            pHatch->getAssocObjIds(dbObjIds);

            // Post hatch entity to database
            //
            // Attach hatchId to all source boundary objects for notification.
            //
            AcDbEntity *pEnt;
            int numObjs = dbObjIds.length();
            Acad::ErrorStatus es;
            for (int i = 0; i < numObjs; i++)
            {
                es = acdbOpenAcDbEntity(pEnt, dbObjIds[i], AcDb::kForWrite);
                if (es == Acad::eOk)
                {
                    pEnt->addPersistentReactor(hatchID);
                    pEnt->close();
                }
            }
        }

        pHatch->setColorIndex(nColorIndex);
        pHatch->close();
        return hatchID;
    }

 

and there is also an dwg attaced. you can check the two hatches , I found they have the same properties,but look differently.

Technology change world! Coding change technology! We coders are coding!
2 REPLIES 2
Message 2 of 3
owenwengerd
in reply to: 421232206

Try setting your pattern scale before you set the pattern.

--
Owen Wengerd
ManuSoft
Message 3 of 3
421232206
in reply to: owenwengerd

it works, and this imply that arx's  design structure is somehow ,not clear, or uneasy to developers to understand.

anyway, thanks a lot

Technology change world! Coding change technology! We coders are coding!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost