Author Topic: Draw a simple line...  (Read 10792 times)

0 Members and 1 Guest are viewing this topic.

LE

  • Guest
Draw a simple line...
« on: November 16, 2005, 12:08:40 AM »
Here is a function to draw a simple LINE on model or paper space.

The code does not have any descriptions or comments.

Code: [Select]
static int ads_myline(void)
{
struct resbuf *pArgs =acedGetArgs () ;

if( !pArgs ||
pArgs->restype != RTPOINT ||
!pArgs->rbnext ||
pArgs->rbnext->restype != RTPOINT ||
pArgs->rbnext->rbnext )

{
ads_point& pnt1 = pArgs->resval.rpoint;
AcGePoint3d pntStart( pnt1[X], pnt1[Y], pnt1[Z] );

ads_point& pnt2 = pArgs->rbnext->resval.rpoint;
AcGePoint3d pntEnd( pnt2[X], pnt2[Y], pnt2[Z] );

}

Usage: (myline (getpoint "\nFrom: ") (getpoint "\nTo: "))
« Last Edit: December 07, 2005, 10:52:13 AM by LE »

LE

  • Guest
Re: Draw a simple line...
« Reply #1 on: November 16, 2005, 12:14:49 AM »
I posted myline function because all the functions or samples on how to draw a line with objectARX on books or in the net [at least by my research], are not complete and do not have the ability to pick the points or to draw the line on paper or model space....

MickD

  • Gator
  • Posts: 3244
  • !false...it's funny 'cause it's true!
Re: Draw a simple line...
« Reply #2 on: November 16, 2005, 12:18:45 AM »
So, do you use this in a lisp routine calling 'myline' with some user input from lisp which calls ads_myline passing in the arg's?

I've never looked at ads or linking  with lisp. You would still need your entry point etc yes?
A programmer's wife tells him, "Run to the store and pick up a loaf of bread. If they have eggs, get a dozen."

The programmer comes home with 12 loaves of bread.

LE

  • Guest
Re: Draw a simple line...
« Reply #3 on: November 16, 2005, 12:23:19 AM »
So, do you use this in a lisp routine calling 'myline' with some user input from lisp which calls ads_myline passing in the arg's?

I've never looked at ads or linking  with lisp. You would still need your entry point etc yes?

I am creating my solution using the ARXwizard, by default if you make a function it will place an ads_yourFunctionNameGoesHere.

With the ARXwizard, the code basic or skeleton are generated.... is kind of different as the normal entry point.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Draw a simple line...
« Reply #4 on: November 16, 2005, 12:26:19 AM »
Hi Luis

Just an academic question ..
I've noticed you prefix a lot of your functions with ads_
Is there any special reason you use this prefix ... I usually associate it with Acad prefix for translations of the original Lisp routines into C.


Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

LE

  • Guest
Re: Draw a simple line...
« Reply #5 on: November 16, 2005, 12:27:51 AM »
Code: [Select]
//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CLSP2ARXApp)

ACED_ADSSYMBOL_ENTRY_AUTO(CLSP2ARXApp, myline, false)
« Last Edit: November 16, 2005, 10:04:10 AM by LE »

LE

  • Guest
Re: Draw a simple line...
« Reply #6 on: November 16, 2005, 12:30:05 AM »
Hi Luis

Just an academic question ..
I've noticed you prefix a lot of your functions with ads_
Is there any special reason you use this prefix ... I usually associate it with Acad prefix for translations of the original Lisp routines into C.


The reason is that I am using the ARXwizard that comes with the ObjectARX SDK.... and by default will add the reserved ads_ prefix.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Draw a simple line...
« Reply #7 on: November 16, 2005, 12:34:16 AM »
Thanks,
I was posting that ques' while you were answering Mick ...

again, purely an academic question ;
Can you change it to something else and still have it work ?

Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

MickD

  • Gator
  • Posts: 3244
  • !false...it's funny 'cause it's true!
Re: Draw a simple line...
« Reply #8 on: November 16, 2005, 12:37:25 AM »
Aha! this little macro is where the majic happens -


ACED_ADSSYMBOL_ENTRY_AUTO(CLSP2ARXApp, myline, false)
A programmer's wife tells him, "Run to the store and pick up a loaf of bread. If they have eggs, get a dozen."

The programmer comes home with 12 loaves of bread.

LE

  • Guest
Re: Draw a simple line...
« Reply #9 on: November 16, 2005, 12:46:05 AM »
Thanks,
I was posting that ques' while you were answering Mick ...

again, purely an academic question ;
Can you change it to something else and still have it work ?



Hi Kerry,

I think so, but manually also all the occurrences, I have not done it that way.... the wizard have the ability to make a name change automatically.

LE

  • Guest
Re: Draw a simple line...
« Reply #10 on: November 16, 2005, 12:47:32 AM »
Aha! this little macro is where the majic happens -


ACED_ADSSYMBOL_ENTRY_AUTO(CLSP2ARXApp, myline, false)

That's the beauty of using the wizard....

[See, ya' tomorrow.... time to zzzZZZ]

deegeecees

  • Guest
Re: Draw a simple line...
« Reply #11 on: November 16, 2005, 11:16:47 AM »
Have a good sleep LE.

So, could someone explain to me the steps involved to make myline work. I ask only that you explain it to me like I'm a fourth grader, as I have never dealt with ARX before, and would like to learn.  :-)

Swift

  • Swamp Rat
  • Posts: 595
Re: Draw a simple line...
« Reply #12 on: November 16, 2005, 11:30:12 AM »
I believe that code is the c based ads and not the c++ arx

LE

  • Guest
Re: Draw a simple line...
« Reply #13 on: November 16, 2005, 11:42:18 AM »
I believe that code is the c based ads and not the c++ arx

It is pure ObjectARX, what happens is that if you use the ARXwizard available from the ARX-SDK installation, that will make the use of the ads_prefix. No relation with the ADS.

I will post the normal alternative and the ADS version, just to notice the difference.


Thanks.

Swift

  • Swamp Rat
  • Posts: 595
Re: Draw a simple line...
« Reply #14 on: November 16, 2005, 11:43:35 AM »
I think this will draw a line in arx, I haven't compiled it for a check...

Code: [Select]
AcDbDatabase *pCurrentDB; // pointer to hole current drawing database
AcGePoint3d stpt(0.0,0.0,0.0); //3d starting point
AcGePoint3d endpt(5.0,5.0,0.0);; //3d ending point
AcDbLine *acLine = new AcDbLine(stpt, endpt); // create a new newline
pCurrentDB = acdbHostApplicationServices()->workingDatabase(); // set pointer to workling database
AcDbBlockTable *pBlockTable;
pCurrentDB->getBlockTable(pBlockTable, AcDb::kForRead); //get the block table
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite); // get a blocktablerecord
pBlockTable->close();
AcDbObjectId lineId;
pBlockTableRecord->appendAcDbEntity(lineId, acLine); // Actually adds the line to the drawing
pBlockTableRecord->close();
acLine->close();
Code: [Select]