recreating AcDbBlockReference functionality

recreating AcDbBlockReference functionality

Anonymous
Not applicable
575 Views
4 Replies
Message 1 of 5

recreating AcDbBlockReference functionality

Anonymous
Not applicable
OK, here’s my story.....

I’m currently working on a fire protection design application; it’s basically just an overgrown dimension. The main part is, CPsDbSprinklerLine derived from AcDbEntity, which is displayed as a line with text above and below, then, at the end of the line I would like to display an instance of an AcDbBlockTableRecord. But I’m having a bit of trouble figuring out to best way to display an instance of said, AcDbBlockTableRecord.


It’s kind of set up like this (logically not technically)...............

class CPsDbSprinklerLine : public AcDbEntity
{
.....etc....
AcGePoint3d m_pt3dStart; <---- used as block position
AcGePoint3d m_pt3dEnd;
AcDbHardPointerId m_objIdBlockRecord;
double m_dBlockScaleX;
double m_dBlockScaleY;
double m_dBlockScaleZ;
double m_dBlockRotation;

............etc......
};

I guess I’m just looking for and explanation of how, exactly, the AcDbBlockReference works. I’m thinking that I need to write, CPsDbSprinklerLine::BlockTransform() that returns the same type of AcGeMatrix3d as the AcDbBlockReference.

The implementation of CPsDbSprinklerLine::worldDraw(AcGiWorldDraw* mode) would be along the lines of............

for each AcDbEntity located within CPsDbSprinklerLine ::m_objIdBlockRecord
{
clone the AcDbEntity;
apply AcGeMatrix3d returned from CPsDbSprinklerLine::BlockTransform();
call AcDbEntity::worldDraw(mode);
delete previously cloned AcDbEntity;
};
draw other necessary components........

This does not sound at all correct though, it seems very sloppy. If it was me, I would have a function written into AcDbBlockTableRecord to display itself transformed by a given AcGeMatrix3d. I looked for such a function but couldn’t find anything like it, I also couldn’t find any implementation details of AcDbBlockReference either.

Another problem I’m having is trying to find some function in ObjectArx/Dbx that will let me tell AutoCAD to search for a file within the realms of its support path directories. I looked at AcDbHostApplicationServices::findFile() but it is pure virtual and it’s not even close.

I’m again basically trying to recreate the AcDbBlockReference and INSERT functionality; when the user asks to put a block on the end of the CPsDbSprinklerLine that is not loaded into the current AcDbBlockTable, I would like to search through the AutoCAD support directories for the requested block, exactly the same way INSERT does. I would like to try to avoid using acedCommand() because I’m not actually going to be creating any instance of AcDbBlockReference, the AcDbBlockTableRecord is kept from being purged with CPsDbSprinklerLine::m_objIdBlockRecord.

Pre-Thanks to anyone who could give any helpful information, your time is much appreciated.
0 Likes
576 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
I think you'll be better served using an AcDbBlockReference* as a class member
variable (don't add it to the database) instead of trying to reinvent the wheel.
You can just call it's worldDraw() in your worldDraw() override. This way
you can get rid of all the variables you are using to keep track of the
geometry's transform. Your AcDbHardPointerId prevents the block table record
from getting purged.

findFile() should be available from ObjectDBX via
acdbHostApplicationServices()->findFile(...). Being pure virtual just ensures
that the host application overrides it in some fashion. If it fails you need to
bail or prompt the user for the dwg file.

--
|
----+----------------------------------------------
| Byron Blattel
| CADwerx---Applications for AutoCAD
| Autodesk Registered Developer
| email: [email protected]
| web site: http://www.cadwerx.net
|
0 Likes
Message 3 of 5

Anonymous
Not applicable
I didn't use AcDbBlockReference as a (memory only) data member because I don't actually have data such as, scale and rotation included in my custom entity. I was just describing the logical aspects so it would be easier to understand my dilemma.



The second half of this project includes a class called CPsDbSprinklerStyle which is similar to dimension style.
All data that differs from what is listed in CPsDbSprinklerStyle is created on a per-need basis. The custom entity basically just has two AcGePoint3d data members and a AcDbHardPointerId to the style that it needs.



When worldDraw() gets called the custom entity opens its CPsDbSprinklerStyle, temporarily overlays it’s style overrides and then extracts the needed data for display.



But yes, I have quite a tendency to reinvent the wheel.


0 Likes
Message 4 of 5

Anonymous
Not applicable
Actually Byron,



Now that I had thought about it for two days straight, I think I have worked out a way to implement my project in a way similar to what you have suggested. I most likely would have never thought of writing it such a way if you hadn’t gotten my mind on the AcDbBlockReference tangent.



I thank you for you input.



Have a good day!


0 Likes
Message 5 of 5

Anonymous
Not applicable
TheRooster wrote:
> Actually Byron,
>
> Now that I had thought about it for two days straight, I think I have
> worked out a way to implement my project in a way similar to what you
> have suggested. I most likely would have never thought of writing it
> such a way if you hadn’t gotten my mind on the AcDbBlockReference tangent.
>
> I thank you for you input.
>
> Have a good day!
>
You're welcome 🙂

Since you know where the ends of your line are and you can calculate the angle
on the current view plane, all you need is the scale to build the transform.

--
|
----+----------------------------------------------
| Byron Blattel
| CADwerx---Applications for AutoCAD
| Autodesk Registered Developer
| email: [email protected]
| web site: http://www.cadwerx.net
|
0 Likes