Active Member
8 Posts
0 Kudos
Registered: ‎02-06-2012
Post 1 of 4

AcDbBlockReference jig problem (duplicated)

490 Views, 3 Replies
02-06-2012 11:24 AM

I'm trying to implement a custom Jig to Block References.

My Block have just one circle and many attributes, which just 3 of them are visible.

I had a hard time to figure out how to make the visible attributes to show during the drag, just the circle was showing up.

After reading this:


I learned that Block Reference should be on the database after the drag begin.

Now I have a jig showing my BlockReference complete, but there are two copies on the screen, one in the right place (in the cursor position) and another about 2*(X,Y), like a ghost (maybe more like a twin, because it isn't fading).

My function tha makes the Jig work:

//This is object has my block reference
this->tmpPv = new PV;
//Solution of blog throught-the-interface
//A map with attributes tags and their positions
AcDbObjectId* pBlockId = PV::getBlockId(); //Get the Id of de Block Definition
AcDbBlockTableRecord* pBlockTableRecord;
acdbOpenObject(pBlockTableRecord, *pBlockId, AcDb::kForWrite);
AcDbBlockTableRecordIterator* pBlockTableRecordIterator;
AcDbEntity *pEnt;
AcDbAttributeDefinition *pAttdef;
//For each attribute: include it on the MAP whit the position
for(pBlockTableRecordIterator->start(); !pBlockTableRecordIterator->done(); pBlockTableRecordIterator->step()) {
	pBlockTableRecordIterator->getEntity(pEnt, AcDb::kForRead);
	pAttdef = AcDbAttributeDefinition::cast(pEnt);
	if (pAttdef != NULL && !pAttdef->isConstant()) {
		map[pAttdef->tag()] = pAttdef->position();
delete pBlockTableRecordIterator;
AcEdJig::DragStatus status = drag();
if(status == AcEdJig::kNormal) {
	return this->tmpPv;
} else if(status == AcEdJig::kCancel) {
    //TODO: Remove the Block from the database
return NULL;
delete this->tmpPv;

 Then my AcEdJig::update:

this->tmpPv is the object with the pointer to my AcDbBlockReference (getBlockReference())

this->tmpCenterPoint is my new point (from the sampler method)

AcDbObjectIterator* itr = this->tmpPv->getBlockReference()->attributeIterator();
AcDbAttribute *pAtt;
AcGePoint3d pAuxPoint = tmpCenterPt;
for(itr->start(); !itr->done(); itr->step()) {
	AcDbObjectId pAttId = itr->objectId();
	this->tmpPv->getBlockReference()->openAttribute(pAtt, pAttId, AcDb::kForWrite);
	if (pAtt != NULL && !pAtt->isConstant()) {
		pAuxPoint = tmpCenterPt;
		pAuxPoint += map[pAtt->tag()].asVector();
delete itr;
return Adesk::kTrue;

 My main problem is that there are two blocks references showing up during the drag, when I click just the correct one stays

Distinguished Mentor
739 Posts
100 Kudos
Registered: ‎08-06-2002
Post 2 of 4

Re: AcDbBlockReference jig problem (duplicated)

02-06-2012 11:54 AM in reply to: rgppp

What you are trying to do is almost certainly not going to work. Adding the jigged object to the database introduces all sorts of problems that you haven't even encountered yet. It would be much easier to create a custom object that encapsulates your visible graphics in a single object, then jig that object. Once the jig is complete, you can delete the custom object and add an actual block reference to the database if that is what you want to end up with.


Owen Wengerd



Owen Wengerd
Active Member
8 Posts
0 Kudos
Registered: ‎02-06-2012
Post 3 of 4

Re: AcDbBlockReference jig problem (duplicated)

02-06-2012 12:10 PM in reply to: owenwengerd

It does work, not as it should :smileyvery-happy:
The object is created and inserted in database only once. I can choose on AutoCad where to place it, the problem is that the object is showing duplicated, but at the end I have just the block reference  in the right position.
I liked our suggestion, It didn't cross my mind. But i really want to solve this issue, for the honor

158 Posts
10 Kudos
Registered: ‎12-07-2009
Post 4 of 4

Re: AcDbBlockReference jig problem (duplicated)

01-31-2013 02:09 AM in reply to: rgppp

Same problem here.


A little suggestion: instead of using setPosition and loop on each attribute to set position, you should call transformBy. The main advantage is that you don't need to care about attributes and you can apply rotation and scale.





Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!