Simply assign Start/Endpoint of a Line Entity

Simply assign Start/Endpoint of a Line Entity

Anonymous
Not applicable
304 Views
3 Replies
Message 1 of 4

Simply assign Start/Endpoint of a Line Entity

Anonymous
Not applicable
Hello there,

Im an ARX beginner (Charles McAuley : Programming Autocad 2000 / Chapter 3).
For exercise I translate my old ADS-Applications into ARX.

I have the Problem to get the position Informations (DXF Code 10 and 11)
of a Line Entitiy without resultbuffers.
I think the answer is simple but i dont get it.


ads_point pt;
ads_name en;
acedEntSel("\nSelect an Line Entity: ",en,pt); // ! Snip Error checking ONLY
LINES !

AcGePoint3d StartingLine; // for getting the startpoint of the Line
AcGePoint3d EndingLine; // for getting the endpoint of the Line


AcDbObjectId objId; // def Object Id
acdbGetObjectId(objId,en); // get Objext Id
AcDbObject *pObj; // Pointer of type AcDbObject
acdbOpenObject(pObj, objId, AcDb ::kForRead);

???????? HOW CAN I assign
the points: StartingLine and Endingline now
??????????

pObj->Close

Thank you for helping a newbie
Dennis
0 Likes
305 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Dennis,

As you have a pointer to AcDbObject you need to downcast the pointer to have
access to AcDbLine specific functions.

----------------------------------------------------------------------------
--------------
// First you need to cast the pointer.
// Note that as we know that AcDbLine derives from AcDbObject this cast must
work

AcDbLine* pLine = AcDbLine::cast(pObj); // Safe cast. Don't use pLine =
(AcDbLine*)pObj

// Check if cast was successful
if (pLine != NULL) {
pLine->setStartPoint(StartingLine);
pLine->setEndPoint(EndingLine);
}

// Now, as pLine and pObj points to the same thing, you just need to close
one of them, in this case pObj.
// Don't close pLine!

pObj->close();
----------------------------------------------------------------------------
--------------

Also I would recommend you to check if acdbOpenObject() was succeeded
checking its return value:
if (acdbOpenObject(...) == Acad::eOk) {
// Do all the rest inside this statement
}

Regards,
Fernando.


"Dennis Meier" wrote in message
news:E5A8827AE7A4C7412776AE1E5E58DB86@in.WebX.maYIadrTaRb...
> Hello there,
>
> Im an ARX beginner (Charles McAuley : Programming Autocad 2000 / Chapter
3).
> For exercise I translate my old ADS-Applications into ARX.
>
> I have the Problem to get the position Informations (DXF Code 10 and 11)
> of a Line Entitiy without resultbuffers.
> I think the answer is simple but i dont get it.
>
>
> ads_point pt;
> ads_name en;
> acedEntSel("\nSelect an Line Entity: ",en,pt); // ! Snip Error checking
ONLY
> LINES !
>
> AcGePoint3d StartingLine; // for getting the startpoint of the Line
> AcGePoint3d EndingLine; // for getting the endpoint of the Line
>
>
> AcDbObjectId objId; // def Object Id
> acdbGetObjectId(objId,en); // get Objext Id
> AcDbObject *pObj; // Pointer of type AcDbObject
> acdbOpenObject(pObj, objId, AcDb ::kForRead);
>
> ???????? HOW CAN I assign
> the points: StartingLine and Endingline now
> ??????????
>
> pObj->Close
>
> Thank you for helping a newbie
> Dennis
>
>
>
>
>
>
0 Likes
Message 3 of 4

Anonymous
Not applicable
try this, then you'll have a pointer to a line entity.

AcDbLine *pLine; // Pointer of type AcDbLine
> acdbOpenAcDbEntity((AcDbEntity *&) pLine, objId, AcDb ::kForRead);

Joerg

Dennis Meier schrieb in im Newsbeitrag:
E5A8827AE7A4C7412776AE1E5E58DB86@in.WebX.maYIadrTaRb...
> Hello there,
>
> Im an ARX beginner (Charles McAuley : Programming Autocad 2000 / Chapter
3).
> For exercise I translate my old ADS-Applications into ARX.
>
> I have the Problem to get the position Informations (DXF Code 10 and 11)
> of a Line Entitiy without resultbuffers.
> I think the answer is simple but i dont get it.
>
>
> ads_point pt;
> ads_name en;
> acedEntSel("\nSelect an Line Entity: ",en,pt); // ! Snip Error checking
ONLY
> LINES !
>
> AcGePoint3d StartingLine; // for getting the startpoint of the Line
> AcGePoint3d EndingLine; // for getting the endpoint of the Line
>
>
> AcDbObjectId objId; // def Object Id
> acdbGetObjectId(objId,en); // get Objext Id
> AcDbObject *pObj; // Pointer of type AcDbObject
> acdbOpenObject(pObj, objId, AcDb ::kForRead);
>
> ???????? HOW CAN I assign
> the points: StartingLine and Endingline now
> ??????????
>
> pObj->Close
>
> Thank you for helping a newbie
> Dennis
>
>
>
>
>
>
0 Likes
Message 4 of 4

Anonymous
Not applicable
Just replace this:

> AcDbObject *pObj;
> acdbOpenObject(pObj, objId, AcDb ::kForRead);

AcDbLine* pLine = NULL;
acdbOpenObject(pLine, objId, AcDb ::kForRead);

"Dennis Meier" az alábbiakat írta a következo üzenetben:
news:E5A8827AE7A4C7412776AE1E5E58DB86@in.WebX.maYIadrTaRb...
> Hello there,
>
> Im an ARX beginner (Charles McAuley : Programming Autocad 2000 / Chapter
3).
> For exercise I translate my old ADS-Applications into ARX.
>
> I have the Problem to get the position Informations (DXF Code 10 and 11)
> of a Line Entitiy without resultbuffers.
> I think the answer is simple but i dont get it.
>
>
> ads_point pt;
> ads_name en;
> acedEntSel("\nSelect an Line Entity: ",en,pt); // ! Snip Error checking
ONLY
> LINES !
>
> AcGePoint3d StartingLine; // for getting the startpoint of the Line
> AcGePoint3d EndingLine; // for getting the endpoint of the Line
>
>
> AcDbObjectId objId; // def Object Id
> acdbGetObjectId(objId,en); // get Objext Id
> AcDbObject *pObj; // Pointer of type AcDbObject
> acdbOpenObject(pObj, objId, AcDb ::kForRead);
>
> ???????? HOW CAN I assign
> the points: StartingLine and Endingline now
> ??????????
>
> pObj->Close
>
> Thank you for helping a newbie
> Dennis
>
>
>
>
>
>
0 Likes