Hi Andrew:
I want to develop a pat file creator based in qcad, which can open in autocad. I want to explode the hatch entity so that autocad can show the user-defined hatch.the problem is I called getpainterpath of REntity(not solid and draft == false), but it returnd QList<RPainterPath> is empty. hope can get some help from you, thanks very much.
Hatch explode
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Re: Hatch explode
Please refer to Explode.js for an example:
https://github.com/qcad/qcad/blob/maste ... Explode.js
(search for "Hatch").
https://github.com/qcad/qcad/blob/maste ... Explode.js
(search for "Hatch").
Re: Hatch explode
Hi Andrew,
Thanks for the reply!
I tried but at line No.258 of Explode.js, the method getPainterPaths(false) always returned empty QList, and the reason is RHatchData::getSegments() always returned empty QList either. I tried many times but still cannot figure why. Thank you so much.
//to draw hatch
//to explode hatch
Thanks for the reply!
I tried but at line No.258 of Explode.js, the method getPainterPaths(false) always returned empty QList, and the reason is RHatchData::getSegments() always returned empty QList either. I tried many times but still cannot figure why. Thank you so much.
//to draw hatch
Code: Select all
RHatchData *pData = new RHatchData(false, 1, fRotation * M_PI /180, sPatName);
pData->setDocument(&pDocIf->getDocument());
pData->newLoop();
QList<RVector> verticList = area.getVertices();
for(int i = 0; i < verticList.size() - 1; i++)
{
QSharedPointer<RShape> sp(new RLine(verticList[i], verticList[i + 1]));
pData->addBoundary(sp);
if(verticList.size() - 2 == i)
{
QSharedPointer<RShape> sp(new RLine(verticList[i + 1], verticList[0]));
pData->addBoundary(sp);
}
};
pData->setLineweight(RLineweight::Weight005);
RHatchEntity* pEntity = new RHatchEntity(&pDocIf->getDocument(), *pData);
QSharedPointer<RObject> spHatchEntity(pEntity);
RAddObjectsOperation operation;
operation.addObject(spHatchEntity, false, false);
operation.apply(pDocIf->getDocument());
Code: Select all
QSet<REntity::Id> entityIds = pDocIf->getDocument().queryAllEntities();
foreach (REntity::Id id, entityIds)
{
QSharedPointer<REntity> e = pDocIf->getDocument().queryEntity(id);
if(RS::EntityType::EntityHatch == e->getType())
{
QSharedPointer<RHatchEntity> hEntity = e.dynamicCast<RHatchEntity>();
if(hEntity.isNull())
{
continue;
}
QString sName = hEntity->getData().getPatternName();
{
QList<RPainterPath> painterPaths = hEntity->getPainterPaths(false); //painterPaths is always empty :(
//...
}
}
}
Re: Hatch explode
I'd suggest to export your programmatically generated data to DXF (using RDocumentInterface::exportFile("myfile.dxf")) and load that DXF in QCAD to check if the data is correct.
Re: Hatch explode
Hi Andrew:
Saving "YJG_5671fa409d.pat" of attchments in qcad path "QCAD\patterns\metric" then opening the test.dxf, you will see the hatch style. It can be exploded in qcad but it won't work in qcad project because of previous reasons.
Thank you so much.
Saving "YJG_5671fa409d.pat" of attchments in qcad path "QCAD\patterns\metric" then opening the test.dxf, you will see the hatch style. It can be exploded in qcad but it won't work in qcad project because of previous reasons.
Thank you so much.
- Attachments
-
- YJG_5671fa409d.pat
- (86 Bytes) Downloaded 555 times
-
- test.dxf
- (32.6 KiB) Downloaded 557 times
Re: Hatch explode
Hi,
Your pat file ends with '*'
reading your pat:
Infinite line angle 0 start (0,0) dXshift 0 dYoffset 1500
dashed line angle 90 start(0,0) dXshift 1500 dYoffset 1250 ON 1500 OFF 1500
From such a wide hatch not a lot will be seen.
How far did you get with this?
Regards,
CVH
Your pat file ends with '*'
reading your pat:
Infinite line angle 0 start (0,0) dXshift 0 dYoffset 1500
dashed line angle 90 start(0,0) dXshift 1500 dYoffset 1250 ON 1500 OFF 1500
From such a wide hatch not a lot will be seen.
How far did you get with this?
Regards,
CVH