Help, AcDbSortentsTable Class is not working properly in ObjectARX 2019

Help, AcDbSortentsTable Class is not working properly in ObjectARX 2019

7598165
Advocate Advocate
1,305 Views
3 Replies
Message 1 of 4

Help, AcDbSortentsTable Class is not working properly in ObjectARX 2019

7598165
Advocate
Advocate

hello all:

 

For INSERT(AcDbBlockTableRecord), non-Model_Space or Paper_Space

 

AcDbSortentsTable Class is not working properly in ObjectARX 2019.

 

The following code is the entity or selection set , according to the blocktable space belonging to draworder(moveBottom) operation, the code is normal in AUTOCAD 2004-2018, but no effect in 2019.
es = pSt->moveToBottom(ids );
The return value of es is eOk,

 

Ask for help.

 

thanks. 

 

 

搜狗截图20180329151444.png搜狗截图20180329151753.png

 

int moveToBottom()
{
	resbuf *rb = ads_getargs();
	if (!rb)
		return RSRSLT;
	AcDbObjectIdArray ids, ids1;
	AcDbObjectId id;
	Acad::ErrorStatus es;
	int i = 0;
	AcDbObjectId ownerId;
	while (rb) {
		if (rb->restype == RTENAME) {
			if (acdbGetObjectId(id, rb->resval.rlname) == eOk)
			{
				if (!i)
				{
					AcDbEntity *pEnt;
					es = acdbOpenObject(pEnt, id, kForRead);
					if (es == eOk)
					{
						ownerId = pEnt->ownerId();
						pEnt->close();
					}
					else
						return RSRSLT;
				}
				i = 1;
				ids.append(id);
			}
		}
		else if (rb->restype == RTPICKS) {
			es = XdDbUtils::getIdArrayFromPickSet(rb->resval.rlname, ids1);
			if (es != Acad::eOk) {
				rb = rb->rbnext;
				continue;
			}
			if (!i)
			{
				AcDbEntity *pEnt;
				es = acdbOpenObject(pEnt, ids1[0], kForRead);
				if (es == eOk)
				{
					ownerId = pEnt->ownerId();
					pEnt->close();
				}
				else
					return RSRSLT;
			}
			i = 1;
			ids.append(ids1);
		}
		rb = rb->rbnext;
	}
	if (ids.isEmpty())
		return RSRSLT;

	AcDbSortentsTable *pSt=NULL;

	AcDbBlockTableRecord *pRec;
	if (Acad::eOk != acdbOpenObject(pRec, ownerId, AcDb::kForRead))
		return RSRSLT;
	AcDbObjectId ext_id = pRec->extensionDictionary();
	if (AcDbObjectId::kNull == ext_id)
	{
		if (Acad::eOk != pRec->upgradeOpen())
		{
			pRec->close();
			return RSRSLT;
		}
		pRec->createExtensionDictionary();
		ext_id = pRec->extensionDictionary();
		if (AcDbObjectId::kNull == ext_id)
		{
			pRec->close();
			return RSRSLT;
		}
	}
	pRec->close();
	AcDbDictionary *pExt;
	Acad::ErrorStatus es = acdbOpenObject(pExt, ext_id, AcDb::kForRead);
	if (Acad::eOk != es)
		return RSRSLT;
	AcDbObject *pObj;
	if (Acad::eOk != pExt->getAt(_T("ACAD_SORTENTS"), pObj, AcDb::kForWrite))
	{
		if (Acad::eOk != pExt->upgradeOpen())
		{
			pExt->close();
			return RSRSLT;
		}
		pSt = new AcDbSortentsTable;
		if (NULL == pSt)
		{
			pExt->close();
			return NULL;
		}
		AcDbObjectId new_id;
		if (Acad::eOk != pExt->setAt(_T("ACAD_SORTENTS"), pSt, new_id))
		{
			delete pSt;
			pExt->close();
			return NULL;
		}
	}
	else {
		pSt = (AcDbSortentsTable *)pObj;
	}
	pExt->close();
        pSt->setBlockId(ownerId); 	
	es = pSt->moveToBottom(ids);
	pSt->close();
	acedUpdateDisplay();
	ads_rett();
	return RSRSLT;
}

 

0 Likes
1,306 Views
3 Replies
Replies (3)
Message 2 of 4

7598165
Advocate
Advocate

Is the 2019 ARX bug?

who can help me?

 

thanks!!

0 Likes
Message 3 of 4

deepak.a.s.nadig
Alumni
Alumni

Thank you for reporting. 

 

We have updated the Engineering team with this issue.

0 Likes
Message 4 of 4

bim8QKRA
Explorer
Explorer

Any update with this? It is not working either for me in Autocad2019, but it is in 2018

 

(defun c:test ( / acblk acdoc acsel name obj processed )


(setq acdoc (vla-get-activedocument (vlax-get-acad-object))
acblk (vla-get-blocks acdoc)
)
(if (ssget "_X" '((0 . "INSERT")))
(progn
(vlax-for block (setq acsel (vla-get-activeselectionset acdoc))
(if (not (member (setq name (vla-get-name block)) processed))
(
(lambda ( / lst )
(vlax-for obj (vla-item acblk name)
(if (eq "AcDbHatch" (vla-get-objectname obj))
(progn
(setq lst (cons obj lst))
(vla-put-color obj "5")
)
)
)
(if lst
(vla-movetobottom (LM:SortentsTable (vla-item acblk name))
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray vlax-vbobject (cons 0 (1- (length lst)))) lst
)
)
)
)
(setq processed (cons name processed))
)
)
)
)

(vla-regen acdoc acallviewports)
)
)
(princ)
)

(defun LM:SortentsTable ( space / dict result )
(cond
(
(not
(vl-catch-all-error-p
(setq result
(vl-catch-all-apply 'vla-item
(list (setq dict (vla-GetExtensionDictionary space)) "ACAD_SORTENTS")
)
)
)
)
result
)
( (vla-AddObject dict "ACAD_SORTENTS" "AcDbSortentsTable") )
)
)
(vl-load-com) (princ)

0 Likes