<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: noob question on custom classes in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169395#M28441</link>
    <description>Thanks Owen, you and Paul both saw what my myopic eyes didnt !
So are you saying that there is no compelling reason to derive from the 
intrinsic classes,
unless of course you are using members of those classes? Why else would I 
want or need
my classes to "partcipate" in the hierarchy?
I have been pouring over Charles Mcauley's book (programming Autocad 2000 
with Arx)
and attempting to digest the Arx documentation, but inevitably there are 
still unanswered questions.
Thanks again for you patience with this fledglings elementary questions, Im 
sure more will follow!
Perry

"Owen Wengerd" &lt;OWENW&gt; wrote in message 
news:41805423$1_2@newsprd01...
&amp;gt; Perry:
&amp;gt;
&amp;gt;  You only need to derive classes from AcRxObject if you want or need them
&amp;gt; to participate in the Rx class hierarchy.  In the code you posted, you 
&amp;gt; need
&amp;gt; a call to pBlkTableRec-&amp;gt;close() immediately before starting your loop. 
&amp;gt; Then
&amp;gt; move the pBlkTableRec-&amp;gt;close() at the end of the function inside your 
&amp;gt; 'for'
&amp;gt; loop in order to close the open object each time through the loop.  This
&amp;gt; sort of error would be more obvious if the local pBlkTableRec variable
&amp;gt; inside the loop had a different name from the function scope variable. :)
&amp;gt; -- 
&amp;gt; Owen Wengerd
&amp;gt; President, ManuSoft ==&amp;gt; http://www.manusoft.com
&amp;gt; VP Americas, CADLock, Inc. ==&amp;gt; http://www.cadlock.com
&amp;gt;
&amp;gt;&lt;/OWENW&gt;</description>
    <pubDate>Thu, 28 Oct 2004 03:53:43 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2004-10-28T03:53:43Z</dc:date>
    <item>
      <title>noob question on custom classes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169391#M28437</link>
      <description>When creating a custom class in Arx is it mandatory to have it derive from
some intrinsic Arx class (perhaps AcRxObject for "generic" classes)?
For example, I have put into my Arx project a class for reading and writing
INI files. I did not use the Arx wizard, I simply included the .cpp and .h
files and began calling methods from within my app. This seemed to work
fine, I got no errors or warnings and when running the app it operated
on the ini files as expected.
However, I subsequently added another class, again without the Arx wizard,
which was to read/manipulate attribute values of a particular block
insertion. Again I got no complaints from the compiler but after running the
app and attempting to close the drawing Autocad said it couldnt save
because "something" was open for read access. I stepped through the code and
for every occurance of opening a table or record there was
a statement to close it (which seemed to execute), but obviously "something"
did not close.
Im sure the chunk of code (posted below) in question is good, as I stole it
right out of one of the Arxlab samples and we all know that the folks at
AutoDesk write flawless code ;)
So Im wondering if it failed because the class involved was not an
"official" Arx (derived) class?
Also, if ALL my classes MUST be derived from intrinsic ones do I have to use
the Arx wizard to do so? When clicking on that option it complains that my
app is not a Dbx app and tells me to create a Dbx project to use it. My app
does not create any custom entities so it is not a Dbx app
or would any custom class constitute a custom "object" and therefore mean I
have a Dbx app??
On the other hand, if I can create custom classes without deriving, must I
still add the class to the Arx hierarchy and call ::rxinit? I would think
not.
Thanks for any help.

--
Perry Leets
Inovec Optimization and Control Systems
Eugene, Oregon

Here is the code that fails, I have shown the area where if I comment it
out, it will succeed even though it still opens tables and entities...



// titleblock.cpp: implementation of the titleblock class.
//
#include "stdafx.h"
#include "StdArx.h"
#include "resource.h"
#include "titleblock.h"
#include "dbmain.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

titleblock::titleblock()
{
  AcDbEntity *pEnt ;
 AcDbObjectId blockId ;
 AcDbBlockTable *pBlkTable;
 AcDbBlockTableRecord *pBlkTableRec;
 AcDbBlockTableRecordIterator *pBlkRecIter ;
 char *pBlkName;

 acutPrintf("\nIn titleblock constructor");

  // Get the block table
 if ( (es = acdbHostApplicationServices ()-&amp;gt;workingDatabase
()-&amp;gt;getBlockTable (pBlkTable, AcDb::kForRead)) != Acad::eOk )
 {
  acutPrintf ("\nCouldn't open the block table!") ;
  return ;
 }
 // Get the Model Space record and open it for read.
 if ( (es = pBlkTable-&amp;gt;getAt (ACDB_PAPER_SPACE, pBlkTableRec,
AcDb::kForWrite)) != Acad::eOk )
 {
  acutPrintf ("\nCouldn't get Paper Space! Drawing corrupt.\n") ;
  pBlkTable-&amp;gt;close () ;
  return ;
 }
 pBlkTable-&amp;gt;close () ;


 // In this case, the Model Space block table record will provide the
iterator
 // start at the beginning of the record and skip deleted entities

 if ( (es = pBlkTableRec-&amp;gt;newIterator (pBlkRecIter) ) != Acad::eOk )
 {
  acutPrintf ("\nCouldn't create Model Space iterator.") ;
  pBlkTableRec-&amp;gt;close () ;
  return ;
 }

 for ( pBlkRecIter-&amp;gt;start (); !pBlkRecIter-&amp;gt;done () ; pBlkRecIter-&amp;gt;step () )
 {
  // First open each entity for read, just to check its class
  // if it's what we want, we can upgrade open later
  // Don't bother with erased entities
  if ( (es = pBlkRecIter-&amp;gt;getEntity (pEnt, AcDb::kForRead)) != Acad::eOk )
  {
   acutPrintf ("\nCouldn't open entity.");
   continue ;
  }
  if ( pEnt-&amp;gt;isA() != AcDbBlockReference::desc () )
  {
   pEnt-&amp;gt;close () ;
   continue ;
  }

  // At this point there should be no entity open unless its a blockref
  // Get the insert's block table record and compare its name
  // to make sure we've got the right block.  If so, set the layer
  blockId = (AcDbBlockReference::cast (pEnt))-&amp;gt;blockTableRecord () ;
  //    &amp;lt;--- COMMENT OUT start here
  if ( acdbOpenObject ((AcDbObject *&amp;amp;)pBlkTableRec, blockId, AcDb::kForRead)
== Acad::eOk )
  {
   pBlkTableRec-&amp;gt;getName(pBlkName);
   acutPrintf("\n %s", pBlkName);
   if ( strcmp (pBlkName, "title-b2") == 0 )
   {
    if ( pEnt-&amp;gt;upgradeOpen () == Acad::eOk )
     // setLayer also has an overload that takes a layer ID
     // but to avoid global variables we specify the layer name
     pEnt-&amp;gt;setLayer ("0") ;
   }
   pBlkTableRec-&amp;gt;close () ;
   acdbFree (pBlkName) ;
  }
  //    &amp;lt;--- COMMENT OUT end here
  pEnt-&amp;gt;close () ;
 }
 // delete, rather than close, the iterator object
 delete pBlkRecIter ;
 pBlkTableRec-&amp;gt;close () ;
 acutPrintf("\nDone with titleblock constructor");
}


titleblock::~titleblock()
{
 acutPrintf("\nIn titleblock destructor");
  }</description>
      <pubDate>Wed, 27 Oct 2004 20:57:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169391#M28437</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-10-27T20:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: noob question on custom classes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169392#M28438</link>
      <description>You inadvertently left pBlockTableRec open. Close it right&lt;BR /&gt;
before the for loop statement.  I would stay away from the&lt;BR /&gt;
ARX lab examples as their pretty ripe, if you get my meaning.&lt;BR /&gt;
&lt;BR /&gt;
Paul Kohut&lt;BR /&gt;
www.pkautomation.com</description>
      <pubDate>Wed, 27 Oct 2004 23:18:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169392#M28438</guid>
      <dc:creator>pkohut-og</dc:creator>
      <dc:date>2004-10-27T23:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: noob question on custom classes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169393#M28439</link>
      <description>Perry:

  You only need to derive classes from AcRxObject if you want or need them
to participate in the Rx class hierarchy.  In the code you posted, you need
a call to pBlkTableRec-&amp;gt;close() immediately before starting your loop.  Then
move the pBlkTableRec-&amp;gt;close() at the end of the function inside your 'for'
loop in order to close the open object each time through the loop.  This
sort of error would be more obvious if the local pBlkTableRec variable
inside the loop had a different name from the function scope variable. :)
-- 
Owen Wengerd
President, ManuSoft ==&amp;gt; http://www.manusoft.com
VP Americas, CADLock, Inc. ==&amp;gt; http://www.cadlock.com</description>
      <pubDate>Thu, 28 Oct 2004 02:06:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169393#M28439</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-10-28T02:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: noob question on custom classes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169394#M28440</link>
      <description>Right on Paul !
You know, I musta looked at this code for 2 hours and swore that all objects 
were freed, all tables were closed, all buttons buttoned and all snaps 
snapped.
Although Im new to C/Arx I've been coding for several years and I shoulda 
learned by now that the longer I stare at a piece of code, the less I see !
Thanks for clearing up my vision :)
Perry

"pkohut" &lt;NOSPAM&gt; wrote in message 
news:7113598.1098919122375.JavaMail.jive@jiveforum2.autodesk.com...
&amp;gt; You inadvertently left pBlockTableRec open. Close it right
&amp;gt; before the for loop statement.  I would stay away from the
&amp;gt; ARX lab examples as their pretty ripe, if you get my meaning.
&amp;gt;
&amp;gt; Paul Kohut
&amp;gt; www.pkautomation.com&lt;/NOSPAM&gt;</description>
      <pubDate>Thu, 28 Oct 2004 03:31:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169394#M28440</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-10-28T03:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: noob question on custom classes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169395#M28441</link>
      <description>Thanks Owen, you and Paul both saw what my myopic eyes didnt !
So are you saying that there is no compelling reason to derive from the 
intrinsic classes,
unless of course you are using members of those classes? Why else would I 
want or need
my classes to "partcipate" in the hierarchy?
I have been pouring over Charles Mcauley's book (programming Autocad 2000 
with Arx)
and attempting to digest the Arx documentation, but inevitably there are 
still unanswered questions.
Thanks again for you patience with this fledglings elementary questions, Im 
sure more will follow!
Perry

"Owen Wengerd" &lt;OWENW&gt; wrote in message 
news:41805423$1_2@newsprd01...
&amp;gt; Perry:
&amp;gt;
&amp;gt;  You only need to derive classes from AcRxObject if you want or need them
&amp;gt; to participate in the Rx class hierarchy.  In the code you posted, you 
&amp;gt; need
&amp;gt; a call to pBlkTableRec-&amp;gt;close() immediately before starting your loop. 
&amp;gt; Then
&amp;gt; move the pBlkTableRec-&amp;gt;close() at the end of the function inside your 
&amp;gt; 'for'
&amp;gt; loop in order to close the open object each time through the loop.  This
&amp;gt; sort of error would be more obvious if the local pBlkTableRec variable
&amp;gt; inside the loop had a different name from the function scope variable. :)
&amp;gt; -- 
&amp;gt; Owen Wengerd
&amp;gt; President, ManuSoft ==&amp;gt; http://www.manusoft.com
&amp;gt; VP Americas, CADLock, Inc. ==&amp;gt; http://www.cadlock.com
&amp;gt;
&amp;gt;&lt;/OWENW&gt;</description>
      <pubDate>Thu, 28 Oct 2004 03:53:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169395#M28441</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-10-28T03:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: noob question on custom classes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169396#M28442</link>
      <description>Perry:

&amp;gt; So are you saying that there is no compelling reason to derive from the
&amp;gt; intrinsic classes, unless of course you are using members of those
classes?

  Exactly.  Furthermore, even when you do derive from Rx classes, you don't
always need to give your class a new Rx class name (that is, you omit the
ACRX_DECLARE_MEMBERS and ACRX...DEFINE_MEMBERS macros).


&amp;gt; Why else would I want or need my classes to "partcipate" in the hierarchy?

  Two reasons are that you want it to be possible for your objects to be
database resident or you want to utilize the run-time type identification
mechanism that ARX provides. :)
-- 
Owen Wengerd
President, ManuSoft ==&amp;gt; http://www.manusoft.com
VP Americas, CADLock, Inc. ==&amp;gt; http://www.cadlock.com</description>
      <pubDate>Thu, 28 Oct 2004 10:48:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169396#M28442</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-10-28T10:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: noob question on custom classes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169397#M28443</link>
      <description>Thanks a bunch for clearing that up Owen :)

--
Perry Leets
Inovec Optimization and Control Systems
Eugene, Oregon
"Owen Wengerd" &lt;OWENW&gt; wrote in message
news:4180ce62$1_3@newsprd01...
&amp;gt; Perry:
&amp;gt;
&amp;gt; &amp;gt; So are you saying that there is no compelling reason to derive from the
&amp;gt; &amp;gt; intrinsic classes, unless of course you are using members of those
&amp;gt; classes?
&amp;gt;
&amp;gt;   Exactly.  Furthermore, even when you do derive from Rx classes, you
don't
&amp;gt; always need to give your class a new Rx class name (that is, you omit the
&amp;gt; ACRX_DECLARE_MEMBERS and ACRX...DEFINE_MEMBERS macros).
&amp;gt;
&amp;gt;
&amp;gt; &amp;gt; Why else would I want or need my classes to "partcipate" in the
hierarchy?
&amp;gt;
&amp;gt;   Two reasons are that you want it to be possible for your objects to be
&amp;gt; database resident or you want to utilize the run-time type identification
&amp;gt; mechanism that ARX provides. :)
&amp;gt; --
&amp;gt; Owen Wengerd
&amp;gt; President, ManuSoft ==&amp;gt; http://www.manusoft.com
&amp;gt; VP Americas, CADLock, Inc. ==&amp;gt; http://www.cadlock.com
&amp;gt;
&amp;gt;&lt;/OWENW&gt;</description>
      <pubDate>Thu, 28 Oct 2004 15:15:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/noob-question-on-custom-classes/m-p/1169397#M28443</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-10-28T15:15:10Z</dc:date>
    </item>
  </channel>
</rss>

