acedssget for COM accessed objects

acedssget for COM accessed objects

karl.sch1983
Advocate Advocate
467 Views
2 Replies
Message 1 of 3

acedssget for COM accessed objects

karl.sch1983
Advocate
Advocate

I had a previous post here to access Civil 3d objects. Thanks to @Alexander.Rivilis  and @zrobert I successfully created the application and was able to manipulate those by accessing properties of relevant objects through com. Taking it to the next step, I got a request to pick an object in the editor and then manipulate its properties. I just cant seem to successfully get the relationship between the picked entity and casting/converting it to the necessary object to manipulate it. I looked at this post and tried to implement something similar.

 

AcDbObjectId id; acdbGetObjectId(id, en);
AcDbObjectPointer<IAeccSurfacePtr> pEnt(id, AcDb::kForWrite);	// is this correct for accessing a surface?

if (pEnt.openStatus() == Acad::eOk)
{
	//manipulate pEnt properties
}

 

of course it fails.

karlsch1983_0-1649709238246.png

Can someone please provide any helpful info on how to cast to the right entity. Any helpful links? I have googled over several days and cannot find anything. I just need to be able to manipulate the picked civil 3d entity which is a surface. Thanks for all your help in advance.

p.s. I also posted this in the Civil3D customization forums here

 

0 Likes
Accepted solutions (1)
468 Views
2 Replies
Replies (2)
Message 2 of 3

zrobert
Advocate
Advocate
Accepted solution

Hello Karl;

I haven't specifically used object selection in a COM environment, but I think this might help you.
This is a link to Kean's blog where he explains the "conversion" of the classic ObjectId to a COM object.
This is a .NET environment, however, the essential line of code is

 

// Let's use the COM API to get a COM reference
// to the hatch (as a base object)

object obj2 = oAcad.ActiveDocument.ObjectIdToObject(
obj.ObjectId.OldId
);

The IAcadDocument* object in the c++ environment also has this method (ObjectIdToObject).
So, when you get the ObjectID, try to convert it to a COM object this way.
I hope it helps you.

Message 3 of 3

karl.sch1983
Advocate
Advocate

Thanks @zrobert, I will explore the ObjectIdToObject method and report back.

0 Likes