AcDbProxyEntity doesn't explode. How to get geometry?

AcDbProxyEntity doesn't explode. How to get geometry?

Anonymous
Not applicable
3,430 Views
15 Replies
Message 1 of 16

AcDbProxyEntity doesn't explode. How to get geometry?

Anonymous
Not applicable

Hi there,

 

Drawing file has proxy objects, which aren't exploded. However AutoCAD can display these objects. As I understanding AutoCAD uses proxy graphics from file for displaying.

 

How can I get geomtery information from AcDbProxyEntity (without parent application)? I try to get geometry through my derrived class AcGiWorldDraw but it cann't handle proxy entity. Any ideas are welcome.

 

PS: I use RealDWG 2015

PPS: sorry for my ugly english

Bayar

0 Likes
3,431 Views
15 Replies
Replies (15)
Message 2 of 16

tbrammer
Advisor
Advisor

You say "I try to get geometry through my derrived class AcGiWorldDraw".

How do you try to do this? Do you provide your own AcGiWorldGeometry that implements all (!) virtual primitve drawing methods of AcGiGeometry and "record" the calls to the primitve drawing routines? This is what I would try. But I don't know if it works for Proxies.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 3 of 16

Anonymous
Not applicable

Yes. I derrived AcGiWorldGeometry, AcGiContext, AcGiSubEntityTraits and AcGiWorld as in example RealDWG\Samples\DumpDWG. But it doesn't work with proxies. Overridden drawing methods of AcGiWorldGeometry weren't called.

0 Likes
Message 4 of 16

Anonymous
Not applicable

i did some moons ago a conversion of drawings, to match certain standards, many of these were comming from ADT, and end using -EXPORTTOAUTOCAD command, as these are AEC and able to be exploded, no idea if these may work in your case, but here is a link to that command usage:

 

https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/AutoC...

 

hth.-

 

afaik, one can implement to leave your custom object, to simple draw your object as schematics or simple graphics, once the dbx is unloaded or not present.

0 Likes
Message 5 of 16

Anonymous
Not applicable

...also i forgot to mention, that on any custom object one can simple could left out the explode part override, then will guess even if is not at proxy stage, it cannot be exploded too, all will depend on the developer, my 0.2cts... 

0 Likes
Message 6 of 16

owenwengerd
Advisor
Advisor

@Anonymous wrote:

But it doesn't work with proxies. Overridden drawing methods of AcGiWorldGeometry weren't called.


What exactly did you try that you expected to result in calls to your AcGiWorldGeometry methods? Called AcDbProxyEntity::worldDraw()? Or AcDbProxyEntity::saveAs()? Or ...?

--
Owen Wengerd
ManuSoft
0 Likes
Message 7 of 16

Anonymous
Not applicable

Hi Owen, sorry for delaying reply.

 

I use an array in my class MyWorldGeometry to keep geometry:

 

class MyWorldGeometry : public AcGiWorldGeometry
{
    ...
        mutable AcDbVoidPtrArray m_entitySet;
}

Adesk::Boolean MyWorldGeometry::circle(const AcGePoint3d& center, const double radius, const AcGeVector3d& normal) const { AcDbCircle *pCircle = new AcDbCircle(center, normal, radius); m_entitySet.append(pCircle); return Adesk::kFalse; }

In other place I try to get this array:

 

   ...
    AcDbProxyEntity *pProxy = (AcDbProxyEntity *)pEnt;
    MyWorldDraw wd;

    if(pProxy->worldDraw(&wd) == Adesk::kFalse)
    {
	return;
    }
    int length = ((MyWorldGeometry*)wd.rawGeometry())->m_entitySet.length();
    for(int i = 0; i < length; ++i)
    {
	AcDbEntity *ent = (AcDbEntity *)((MyWorldGeometry*)wd.rawGeometry())->m_entitySet[i];
        ...
    }
    ...

But variable 'lenght' is always '0'.

 

May be I chose a wrong way for a getting geometry of proxy objects? Or missunderstanding something about work of AcGi classes?

 

Bayar

0 Likes
Message 8 of 16

owenwengerd
Advisor
Advisor

You should be calling AcGiWorldDraw::geometry(), and of course you have to override this function and return your custom MyWorldGeometry instance. I hope that helps.

--
Owen Wengerd
ManuSoft
0 Likes
Message 9 of 16

Anonymous
Not applicable

For a usual objects such as AcDbLine my code works:

 

AcDbLine *pLine = (AcDbLine *)pEnt;
MyWorldDraw wd;

if(pLine->worldDraw(&wd) == Adesk::kTrue)
{
    MyWorldGeometry *g = (MyWorldGeometry*)&wd.geometry();
    //do Something
}

But with AcDbProxyEntity it doesn't work.

 

May be there are some restrictions in RealDWG work with proxy objects?

0 Likes
Message 10 of 16

owenwengerd
Advisor
Advisor

Did you verify that wd.geometry() returns an instance of your MyWorldGeometry? I'm suspicious that you didn't really implement the geometry() function, but just assume the magic powers of casting make the returned object something it's not.

--
Owen Wengerd
ManuSoft
0 Likes
Message 11 of 16

Anonymous
Not applicable

I checked wd.geometry(), it returns MyWorldGeomtry instance.

0 Likes
Message 12 of 16

Anonymous
Not applicable

ObjectARX Developer Guide  "Displaying Proxy Entities" written:

 

"AutoCAD cannot display a proxy entity using the object's worldDraw() or viewportDraw() functions because the parent application is absent. It uses information in the entity's graphics metafile, which contains data derived from the entity's worldDraw() or saveAs() function when the drawing was last saved (with the SAVE or SAVEAS command). The display format is either that of the entity itself, or a bounding box indicating the volume inhabited by the entity. The format is determined by the setting of the PROXYGRAPHICS system variable at the time the drawing is saved. The bounding box format is useful primarily to minimize the size of the output file when the data for custom entities is large."

 

So need to find out another way to get proxy geometry data.

0 Likes
Message 13 of 16

owenwengerd
Advisor
Advisor

You misunderstand the quoted text. It refers to the parent application calling worldDraw(). The AcDbProxyEntity will play the proxy graphics metafile just fine, otherwise these graphics would not be visible in the drawing. If you have implemented your custom AcGiWorldDraw correctly but still get no graphics, then it indicates that either the proxy graphics metafile is empty (no saved proxy graphics) or you've set some context property (frozen layer? PROXYGRAPHICS == 0?) that disables display.

--
Owen Wengerd
ManuSoft
0 Likes
Message 14 of 16

Anonymous
Not applicable

I checked proxy on graphics metafile, frozen layer and PROXYGRAPHICS:

 

AcDbProxyEntity *pProxy = (AcDbProxyEntity *)pEnt;

CString msg;
switch(pProxy->graphicsMetafileType())
{
case AcDbProxyEntity::kNoMetafile:
    msg = _T("kNoMetafile");
    break;
case AcDbProxyEntity::kBoundingBox:
    msg = _T("kBoundingBox");
    break;
case AcDbProxyEntity::kFullGraphics:
    msg = _T("kFullGraphics");
    break;
} //msg = "kNoMetafile"

AcDbLayerTableRecord *pLayer;
if(acdbOpenObject(pLayer, pProxy->layerId(),AcDb::kForRead) == Acad::eOk)
{
    msg = pLayer->isFrozen() ? _T("pLayer->isFrozen() = TRUE") : _T("pLayer->isFrozen() = FALSE");
    pLayer->close();
} //msg = "pLayer->isFrozen() = FALSE"

Adesk::Int16 iSaveProxy = m_pDb->saveproxygraphics();
msg.Format(_T("PROXYGRAPHICS = %i"), iSaveProxy);
//msg = "PROXYGRAPHICS = 1"

  so results are proxy hasn't graphics metafile, layer isn't frozen and variable PROXYGRAPHICS = 1. Anyway AutoCAD can display proxy object. So I think it means that there is a graphics metafile in drawing. What can affect on this?

 

PS: I attached a test file.

0 Likes
Message 15 of 16

Alexander.Rivilis
Mentor
Mentor

I've exploded those proxies without problem (all proxies was in anonymous block *U2)

Code for exploding: http://adn-cis.org/forum/index.php?topic=1060.msg4984#msg4984

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 16 of 16

Anonymous
Not applicable

Hi Alexander,

 

Thanks for reply and code. But in my application pProxy->graphicsMetafileType() returns AcDbProxyEntity::kNoMetafile, so I suspect that proxy doesn't explode. Now I try to figure out why it happens.

 

Bayar

0 Likes