acedSSLength gives invalid result

acedSSLength gives invalid result

Anonymous
Not applicable
922 Views
6 Replies
Message 1 of 7

acedSSLength gives invalid result

Anonymous
Not applicable

Hi, I don't know how to properly title this post. I'll try to describe it.

 

1. Open Autocad

2. Draw 5 lines (let's say paralell lines)

3. Select them all with area (mouse move)

4. Now press shift and holding shift move your mouse from right lower corner into left upper - selecting all the lines.

If you have done all operations well, every line should be now unselected.

 

Now, when my Autocad loads my application, there something different happens. When I select all the lines, I get pickFirstModified and everything is ok.

But when I'm trying to unselect them all (like I have written earlier), pickFirstModified is called, but then:

 

resbuf * p = NULL;
int result = acedSSGetFirst(NULL, &p); //it gives me selection set
if((p != NULL) && (result == RTNORM))
	{
		m_name[0] = p->resval.rlname[0];
		m_name[1] = p->resval.rlname[1];
	
		acutRelRb(p);
	}

//now, I check the length
long len;
int result = acedSSLength(m_name, &len);

This length gives me 4. What's more, the 4 lines on the drawing are actually still selected. Only one is unselected. Does anyone of you knows the reason why?

0 Likes
923 Views
6 Replies
Replies (6)
Message 2 of 7

nick83
Advocate
Advocate

can't understand, what makes you think that you unselect objects?

nevermind)))

for selecting:

 

ads_name _preselect, en1;
AcDbObjectIdArray wantedObjectsToBeSelected;// fill it with ids acedSSAdd(0,0,_preselect);
for (int i = 0; i < wantedObjectsToBeSelected.length(); i++)
{ acdbGetAdsName(en1,wantedObjectsToBeSelected.at(i)); acedSSAdd(en1,_preselect,_preselect);
} acedSSSetFirst(_preselect, NULL);
acedSSFree(_preselect);

to clear selection:

acedSSSetFirst(NULL, NULL);

and, can't remember exactly, but it seems, that  flags ACRX_CMD_USEPICKSET | ACRX_CMD_REDRAW have to be added to your command description

PS: about your code... it must crush autocad )))

if you want to get ids of preselect, you have to use something like this:

AcDbObjectIdArray preSelect(bool clearSelection = false)
{
	AcApDocument * pDoc = acDocManager->mdiActiveDocument();
	acDocManager->lockDocument(pDoc);

	AcDbObjectId eId;
	AcDbObjectIdArray entArr; entArr.removeAll();
	ads_name ent, one_ent;
	long len = 0L;
	struct resbuf *grip_set = NULL, *ents = NULL;
	int res = acedSSGetFirst(&grip_set, &ents);
	if (res == RTNORM)
	{
		if (ents) 
		{
			if (ents ->restype == RTPICKS) 
			{		
				acedSSLength(ents->resval.rlname, &len);

				for (long a = 0; a < len; a++)
				{
					if (ads_ssname(ents->resval.rlname,a,one_ent)!=RTNORM)continue;
					if(acdbGetObjectId(eId, one_ent)!= Acad::eOk)continue;
					entArr.append(eId);
				}
				acedSSFree(ents->resval.rlname);
			}
			acutRelRb(ents);
		}

		if (grip_set) 
		{
			if (grip_set->restype == RTPICKS) acedSSFree(grip_set->resval.rlname);
			acutRelRb(grip_set);
		}
	}

	if (clearSelection)
		acedSSSetFirst(NULL, NULL);

	acDocManager->unlockDocument(pDoc);
	return entArr;
}

 

0 Likes
Message 3 of 7

Anonymous
Not applicable

I don't think you understand my problem. Maybe because title of the post may not be the proper one.

One more time:

 

When I have 5 lines selected and want to unselect them - on the drawing - I can press shift and while holding shift drag mouse over the entities I want to unselect. After this operation, when my application is loaded only one line is unselected. Not all of them.

0 Likes
Message 4 of 7

tbrammer
Advisor
Advisor

You say that your application unintentionally changes the behavior of AutoCAD's Shift-select. And you want to find out why. Right?


Do you use functions that modify the pickfirst set?
Maybe even in reactors?


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

0 Likes
Message 5 of 7

tbrammer
Advisor
Advisor

You posted this recently. Do you use an AcEdSSGetFilter?


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

0 Likes
Message 6 of 7

Anonymous
Not applicable

@tbrammer wrote:
You say that your application unintentionally changes the behavior of AutoCAD's Shift-select. And you want to find out why. Right?


Exactly.


@tbrammer wrote:

You posted this recently. Do you use an AcEdSSGetFilter?


Actually I do. I mean I have this reactor connected to the document, but all the methods are empty.

0 Likes
Message 7 of 7

Anonymous
Not applicable

It has occured that it works fine in Autocad 2014. Code is the same.

0 Likes