找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 2428|回复: 0

ObjectARX Technical Newsletter - December 1999

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-1-7 02:25:21 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
ObjectARX Technical Newsletter - December 1999  
This document is part of    ObjectARX Newsletter Archive     



/Note: the URLs in this posting may be broken into several lines by the
transmission media. Please make sure that you have the full URL before
trying to access it./

/Note: Have you missed a Newsletter issue? Visit our Newsletter archive at
the following URL:/

http://adn.autodesk.com/techsupp/docs/newsletters.htm

Dear ObjectARX developer,

Table of Contents
=================
(1) ObjectARX reactors

    1.1 Introduction
    1.2 AcDbObjectReactor versus AcDbObject!
    1.3 What is the best choice NOD or EXTD?
    1.4 Derive from a class that supports filing protocol
    1.5 One last item!

(2) Reactor classes

(3) Access for all ADN members to the ADT/OMF newsgroup

(4) New Solutions
  

(1) ObjectARX' reactors
=======================

1.1 Introduction
----------------

In AutoCAD there are two main type of reactors (transient and persistent).
Transient reactors are setup by your application to monitor the activity
in the AutoCAD environment while your application is loaded. This kind of
reactor *must* be detached from the subject (object the reactor is
attached to) it is monitoring when your application is unloaded. It is
important to do this because the AutoCAD subsystem will continue to notify
all reactors attached to a subject, even if the application hosting the
reactor code is not present anymore. Persistent reactors provide the same
kind of service as that of a transient reactor, however the only difference
between a persistent reactor and a transient reactor is that a persistent
reactor is database resident. As a result of the persistent reactor being
database resident, the application is not required to recreate and reattach
the persistent reactor types to their subjects, the next time your drawing
and application is loaded into AutoCAD.

1.2 AcDbObjectReactor versus AcDbObject!
----------------------------------------

It may come as a surprise that both AcDbObjectReactor and AcDbObject are
reactors and provide the same kinds of service to your application.
The difference is that a reactor derived from AcDbObject is
persistent and the reactor derived from AcDbObjectReacor is not.

Remember that AcDbObjectReactor is derived from AcRxObject and is
responsible for the RTTI protocol. AcRxObject does not contain filing
protocol. AcDbObject introduces the filing protocol and is also derived
from AcRxObject as a matter of fact.

Both implement the same notification callback methods (cancelled/copied/
erased/...) and can therefore be used to monitor an object in a DWG
database. However, the transient form of the reactor requires that the
application removes the reactor from the subject (object) when the
application hosting the reactor code is being unloaded, or when AutoCAD
exits. However the next time the drawing is loaded into AutoCAD, the
application will not be able to monitor the object again until the
reactors are attached to the objects once again as before. As a result this
operation requires that you to retrieve the object you want to monitor,
which can be slow and/or difficult. The solution in such a case is to use
the persistent form of the reactor. Then the reactor will be
permanently attached to it's subject and will be immediately active,
as long as the application hosting the reactor code is present. If the
application hosting the reactor code is not present, the next time the
object is loaded in AutoCAD, the reactor will be inactive but will remain
attached for later use, because of the persistent nature of the reactor.

Creating a transient reactor is simple, just derive from the reactor base
class and implement the callback method(s) you are interested in. Then
create an instance of the transient reactor and attach it to a subject
using 'addReactor()' to monitor the method(s) of the subject you have
chosen. Do not forgot to remove the transient reactor
(with 'removeReactor()') when you unload your application or AutoCAD
exits.

Creating a persistent reactor is a little more complicated. You are
required to derive from a class which supports filing protocol
(AcDbObject for example) and implement the callback method(s) you are
interested in. Also you need to implement filing methods so that
your persistent reactor can be saved into the DWG file. When you crate
a persistent reactor for the first time in our drawing, create an instance
of the reactor and provide it a valid owner and a valid subject. The
owner is the object which will make sure that the reactor will be saved
into the DWG file. This can be an entity's Extension Dictionary or the
Named Objects Dictionary. We only attach a reactor to a subject to
monitor the subject, however the subject being monitored does not own
the reactor. It is possible for the subject to be the owner reactor
(Extension Dictionary), but remember you still have to provide both
(subject and owner) in order to make everything work correctly.
Usually, a persistent reactor is derived from AcDbObject and the subject
will be an AcDbEntity object (or derived from AcDbEntity). It is very
important to note that an AcDbblockTableRecord cannot own an AcDbObject.
Therefore you will need to add the reactor into a dictionary. The
AutoCAD Named Objects Dictionary (NOD) or the entity's Extension
Dictionary (EXTD) are two suitable locations to append the reactor to.

1.3 What is the best choice NOD or EXTD?
----------------------------------------

It really is a matter of choice and the architecture you propose to use.
Using the EXTD will produce a bigger DWG file. Approximately, 250 bytes
for each EXTD + 250 bytes (minimum) for your reactor and for each entity
where you want a reactor to be attached to. Using the NOD will produce a
smaller DWG file, 250 bytes for the company dictionary in the NOD + 250
bytes (minimum) for your reactor for each entity. But, you have only one
company dictionary and you may share the same reactor instance for all
(or a group) of entities. Using the EXTD of an entity, sharing the same
reactor is not possible.

1.4 Derive from a class that supports filing protocol
-----------------------------------------------------

For persistent reactors, you will have to derive from a class which
supports filing protocol such as AcDbObject.

All objects which support filing protocol can be used as a reactor, so an
entity derived from AcDbLine can also be a reactor of any other object as
long as this object (the subject) is database resident. Usually, AcDbObject
is sufficient, but remember it is not a requirement. Take a look at
the solution sample:

SOLVING CUSTOM ENTITY AS A REACTOR PROBLEMS
/cgi-bin/solution.pl?SID=21858

1.5 One last item!
------------------

When the reactor callback method is being called, it is not always
possible to open the subject for write and modify operations. This is
because the subject is already opened with a 'kNotify' operation. However,
it is sometimes possible to reopen the object for a 'kWrite' operation
using AutoCAD's transaction mechanism. But be aware that it will once
again trigger a reactor call, and that you may create an infinite loop
as a result. Also the reactor may be called when all operations to be
processed have not yet proceeded (i.e. erased() being called when the
object has been erased, but modified() will be called as well just
after and then objectclosed()).

The best approach is to wait for another notification where you are sure
all operations have been completed and that you can safely open the
object again and modify it (AcEditorReactor::commandEnded() for example).
  

(2) Reactor classes
===================

AcRxObject
    Transient Reactors
    ------------------
    AcApDocManagerReactor
    AcApLongTransactionReactor
    AcDbDatabaseReactor
    AcDbObjectReactor
        AcDbEntityReactor
            AcDbRasterImageDefFileAccessReactor
            AcDbRasterImageDefTransReactor
    AcEdInputContextReactor
    AcEdInputPointMonitor
    AcEdInputPointFilter
    AcRxDLinkerReactor
    AcRxEventReactor
        AcEditorReactor
    AcTransactionReactor

    Persistent Reactors
    -------------------
    AcDbObject
        AcDbEntity
            AcDbCurve
                AcDbLine
                ...
            ...
        AcDbdictionary
            ...
        ...

(3) Access for all ADN members to the ADT/OMF newsgroup

We are pleased to announce access to the Architectural
Desktop/Land Development Desktop OMF (autodesk.adn.aec-dev)
newsgroup is now accessible to all ADN members, using the same
password and username as used to access the ObjectARX newsgroup.
The password and username can be found at the following URL:

http://adn.autodesk.com/techsupp/discussion/default.htm

The ADT/OMF newsgroup can be found at the following location:

news://adesknews.autodesk.com/autodesk.adn.aec-dev

We look forward to your participation in this newsgroup.
  

(4) New Solutions
=================

PREVENT ACAD FROM ENTERING ZERO DOC STATE
/cgi-bin/solution.pl?SID=46546

UNDOCUMENTED ADS_REGEN()
/cgi-bin/solution.pl?SID=45058

HOW TO MAKE A NON DATABASE RESIDENT COPY OF A COMPLEX OBJECT
/cgi-bin/solution.pl?SID=13718

HOW TO INSERT AN IMAGE FILE INTO ACAD USING ARX CODE
/cgi-bin/solution.pl?SID=16253

CLONE ON COMPLEX ENTITIES DOES NOT COPY XDATA AND PERSISTENT REACTORS
/cgi-bin/solution.pl?SID=44982

EXPLAIN ACGEVECTOR3D::ANGLETO()
/cgi-bin/solution.pl?SID=45178

HOW TO GET THE NAME OF A BLOCK USING ARX
/cgi-bin/solution.pl?SID=45944

WHEN TO LOCK A DOCUMENT
/cgi-bin/solution.pl?SID=45945

MAKING NON-DATABASE RESIDENT OBJECTS WORK WITH UNDO
/cgi-bin/solution.pl?SID=45066

DXF GROUP CODE 100 MEANING
/cgi-bin/solution.pl?SID=45287

HOW TO CLIP XREFS PROGRAMMETICALLY
/cgi-bin/solution.pl?SID=45413

FREEZELAYERSINVIEWPORT FAILS ON PAPERSPACE VIEWPORT
/cgi-bin/solution.pl?SID=45302

PLOT LOGGING API UTILITY
/cgi-bin/solution.pl?SID=45303

DISPLAY ATTRIBUTE DIALOG AFTER REALTIME ZOOM OR PAN
/cgi-bin/solution.pl?SID=45317

-----------------------------------------------------------------------------
To subscribe or unsubscribe, go to
http://adn.autodesk.com/techsupp/docs/newsletters.htm
-----------------------------------------------------------------------------

     You received this message as a result of your registration
     on the ADN List Server subscription page.  If you no longer wish
     to receive these messages, read the next section, How to use this
     mailing list.

     How to use this mailing list:

     You may unsubscribe from this e-mail newsletter, or subscribe to
     a variety of other informative e-mail newsletters, by returning
     to the ADN List Server subscription page at
       http://adn.autodesk.com/techsupp/docs/newsletters.htm
     and changing your subscription preferences.

     Alternatively, from the subscribed account you can send an e-mail to
     <Majordomo-partnersys@autodesk.com> with the following command in the
     body of your email message:

     unsubscribe <list-name>

     ----------------------------------------------------------------------

     Autodesk Developer Network (ADN) information and events:

     For information on all ADN topics, please visit:
       http://www.autodesk.com/adn

     ----------------------------------------------------------------------

     THIS DOCUMENT IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY.  The
     information contained in this document represents the current view of
     Autodesk Inc. on the issues discussed as of the date of publication.
     Because Autodesk must respond to change in market conditions, it
     should not be interpreted to be a commitment on the part of Autodesk
     and Autodesk cannot guarantee the accuracy of any information
     presented after the date of publication.
     INFORMATION PROVIDED IN THIS DOCUMENT IS PROVIDED 'AS IS' WITHOUT
     WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
     LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
     PARTICULAR PURPOSE AND FREEDOM FROM INFRINGEMENT.
     The user assumes the entire risk as to the accuracy and the use of
     this document. This  document may be copied and distributed subject to
     the following conditions:
     1.   All text must be copied without modification and all pages must
          be included
     2.   All copies must contain Autodesk's copyright notice and any other
          notices provided therein
     3.   This document may not be distributed for profit

     ----------------------------------------------------------------------
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-22 00:17 , Processed in 0.170528 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表