• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk ObjectARX

    Reply
    Distinguished Contributor
    421232206
    Posts: 140
    Registered: ‎10-21-2010
    Accepted Solution

    curious problem about hatch display

    113 Views, 2 Replies
    09-03-2012 08:54 PM

    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.

    Please use plain text.
    Mentor
    Posts: 239
    Registered: ‎08-06-2002

    Re: curious problem about hatch display

    09-03-2012 09:22 PM in reply to: 421232206

    Try setting your pattern scale before you set the pattern.

    --
    Owen Wengerd
    ManuSoft
    Please use plain text.
    Distinguished Contributor
    421232206
    Posts: 140
    Registered: ‎10-21-2010

    Re: curious problem about hatch display

    09-04-2012 01:23 AM 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

    Please use plain text.