Author Topic: Draw a simple line...  (Read 10940 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: 3255
  • !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?
Debugging:
Being the detective in a crime movie where you're also the murderer.

“Someone's sitting in the shade today because someone planted a tree a long time ago.”
- Warren Buffet

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: 3255
  • !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)
Debugging:
Being the detective in a crime movie where you're also the murderer.

“Someone's sitting in the shade today because someone planted a tree a long time ago.”
- Warren Buffet

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]

Swift

  • Swamp Rat
  • Posts: 595
Re: Draw a simple line...
« Reply #15 on: November 16, 2005, 12:03:06 PM »
yup works for 2005

I'll post the solution after lunch if anyone is interested.

MickD

  • Gator
  • Posts: 3255
  • !false...it's funny 'cause it's true!
Re: Draw a simple line...
« Reply #16 on: November 16, 2005, 12:29:54 PM »
I think the ads_ prefix and this style of arx (as shown in Luis' first post) is a throw back to the early days when most if not all customisation was in lisp (before even ads/arx), rather than registering a command on the command stack as in current arx you (or autocad before ads) created your function and with the help of the macro or similar it 'exported' the function for use in lisp.
IOW, this is probably pretty much the reason how and why you can draw a line from lisp.

Just thinking out loud.... :)
Debugging:
Being the detective in a crime movie where you're also the murderer.

“Someone's sitting in the shade today because someone planted a tree a long time ago.”
- Warren Buffet

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16716
  • Superior Stupidity at its best
Re: Draw a simple line...
« Reply #17 on: November 16, 2005, 01:19:27 PM »
If I remember correctly, you can change the prefix designation. You should register your prefix with Autodesk to be sure noone else uses that prefix and thus causes your programming to have issues with other programming. i.e. if there is already a program using ads_myline and you compile this code, there would be competing programming for the exported function and thus one of the programs would not operate properly. I think it has to do maily with object ownership, but right now my memory is failing me.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

MP

  • Seagull
  • Posts: 17339
Re: Draw a simple line...
« Reply #18 on: November 16, 2005, 01:32:34 PM »
Thank you for the code Luis (and Swift, Mick, Troy, Paul, Chuck, Glenn, Mark ... forgive me if the list is not comprehensive).

While I won't be looking at it today I will be down the line, so thank you all in advance (and for those other threads where you folks posted some great c++).

:)
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox