- UID
- 1
- 积分
- 15892
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
ActiveX/VBA Technical Newsletter - January 2000
This document is part of AutoCAD VB(A) 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 AutoCAD ActiveX/VBA Developer,
Table of Contents
-----------------
1 - R14.01 ActiveX objects not all registered properly
2 - AutoCAD r14.01 / AutoCAD 2000 ActiveX object registration conflict
3 - New WHIP! Control solutions
4 - New or Updated Solutions
1 - R14.01 ActiveX objects not all registered properly
------------------------------------------------------
** IACADAPPLICATION AND IACADDOCUMENT NOT REGISTERED PROPERLY
Question:
I just installed AutoCAD R14.01 and I cannot use early binding with
AcadApplicaton and AcadDocument. The followng VB code fails:
<code_begin>
Dim oAcad As AcadApplication
Set oAcad = GetObject(,"AutoCAD.Application")
<code_end>
If I dim oAcad As Object then everything works fine.
Answer:
The IAcadApplication and IAcadDocument interfaces are not registered
properly. You need to merge the following entries into your registry
to fix the problem:
-Cut here-
REGEDIT
HKEY_CLASSES_ROOT\Interface\{372FA490-600C-11cf-93EB-0800099EB3B7} = IAcadApplication
HKEY_CLASSES_ROOT\Interface\{372FA490-600C-11cf-93EB-0800099EB3B7}\TypeLib = {9B5492B0-EC9A-11ce-935A-0800099EB3B7}
HKEY_CLASSES_ROOT\Interface\{372FA490-600C-11cf-93EB-0800099EB3B7}\ProxyStubClsid32 = {00020424-0000-0000-C000-000000000046}
HKEY_CLASSES_ROOT\Interface\{9B5492B1-EC9A-11ce-935A-0800099EB3B7} = IAcadDocument
HKEY_CLASSES_ROOT\Interface\{9B5492B1-EC9A-11ce-935A-0800099EB3B7}\TypeLib = {9B5492B0-EC9A-11ce-935A-0800099EB3B7}
HKEY_CLASSES_ROOT\Interface\{9B5492B1-EC9A-11ce-935A-0800099EB3B7}\ProxyStubClsid32 = {00020424-0000-0000-C000-000000000046}
-Cut here-
Steps to fix the problem:
1. Cut and paste the above code into a text file.
2. Change the file extension to .reg
3. Double-click on the file. (This launches regedit.exe which should
then report a that it successfully merged the entries into the
registry)
2 - AutoCAD R14.01 / AutoCAD 2000 ActiveX object registration conflict
----------------------------------------------------------------------
** IACADUTILITY NOT REGISTERED PROPERLY
A system having ACAD 2000 and Acad R14.01 installed and ACAD 2000 being
invoked at least once (and the VBAIDE).
Question:
While attempting to access the Utility object (from VB using early binding)
the following error message is displayed "Method 'Utility' of object
IAcadDocument failed"
I cannot use early binding with AcadDocument and AcadUtility. The following
VB code fails to access AutoCAD R14.01:
<code_begin>
Dim oAcad As AcadApplication
Dim oAdoc As AcadDocument
Dim oUtl As AcadUtility
Set oAcad = GetObject(,"AutoCAD.Application.14")
Set oAdoc = oAcad.ActiveDocument
Set oUtl = oAdoc.Utility
<code_end>
Answer:
There are two solutions to this problem......
1. To use late binding for AcadApplication, AcadDocument and AcadUtility
object. And of course you can use early binding for all others.
2. The IAcadUtility interface entries (version = 1.0) is overwritten
(version = 1.1) whenever ACAD 2000 is invoked, and hence generates the above
error message. Merge the following entries into your registry to fix the
problem:
-Cut here-
REGEDIT4
[HKEY_CLASSES_ROOT\Interface\{E4F81D8A-6D4A-11cf-93FB-0800099EB3B7}\TypeLib]
@="{9B5492B0-EC9A-11ce-935A-0800099EB3B7}"
"Version"="1.0"
-Cut here-
Steps to register:
1. Cut and paste the above code into a text file.
2. Change the file extension to .reg
3. Double-click on the file. (This launches regedit.exe which should then
report a that it successfully merged the entries into the registry)
In addition to this, also please refer <Solution 12258>.
3 - New WHIP! Control solutions
-------------------------------
** CONTROL WHIP CONTROL IN A HTML PAGE
Question:
Can you show me how to show different dwf files after I've place the Whip
ActiveX in a html page? Please provide both JScript and VBScript versions.
Answer:
You'll need to have some HTML, ActiveX and Java/VB Script knowledge to
achieve this. You can follow the steps below.
1. You can use pretty much any HTML editor. I'm using Visual J++ 6.0 or
Word 2000 here, to place the Whip Control in the page. Notice that the
basic parameters of the control are set.
<code_begin>
<OBJECT classid="CLSID:B2BE75F3-9197-11CF-ABF4-08000996E931" height=405
id=Whip1 name=Whip1 style="LEFT: 0px; TOP: 0px" width=595>
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="_ExtentX" VALUE="15742">
<PARAM NAME="_ExtentY" VALUE="10715">
<PARAM NAME="_StockProps" VALUE="161">
<PARAM NAME="BackColor" VALUE="16777215">
<PARAM NAME="BorderStyle" VALUE="0">
<PARAM NAME="Appearance" VALUE="0">
<PARAM NAME="Filename" VALUE="file://E:\acad2k\SAMPLE\opera.dwf">
<PARAM NAME="View" VALUE="">
<PARAM NAME="namedview" VALUE="">
<PARAM NAME="userinterface" VALUE="On">
<PARAM NAME="layerson" VALUE="">
<PARAM NAME="layersoff" VALUE="">
<PARAM NAME="LocalTmpFilename" VALUE="">
<PARAM NAME="GreekImages" VALUE="1">
<PARAM NAME="HighlightUrls" VALUE="0">
<PARAM NAME="LoadStreamAutomatically" VALUE="1">
<PARAM NAME="MergeDwf" VALUE="0">
<PARAM NAME="ForceArrowKeys" VALUE="0">
<PARAM NAME="ProxyAccessType" VALUE="0">
<PARAM NAME="CursorMode" VALUE="0">
<PARAM NAME="dropfile" VALUE=""></OBJECT>
<coce_end>
Notice that there is a default dwf file opera.dwf is specified. The control's
name is Whip1.
2. To demonstrate how you can switch a dwf file. I've placed two buttons just
below the control. One is named "Show colorwh.dwf" and the other is named
"Show opera.dwf" with the IDs set to Button1 and Button2 respectively.
3. We need a general function that will execute to switch the data source. To
simplify the matter, I hard-coded directory path and file names. You can
modify them as you see fit.
<code_begin>
<script language=JScript>
function changeDwf(ctrl, which)
{
if(which == 1)
ctrl.StreamName = "E:/acad2k/sample/colorwh.dwf"
else if(which == 2)
ctrl.StreamName = "E:/acad2k/sample/opera.dwf"
}
</script>
<script language=VBScript>
function changeDwf2(ctrl, which)
if which = 1 then
ctrl.StreamName = "E:/acad2k/sample/colorwh.dwf"
elseif which = 2 then
ctrl.StreamName = "E:/acad2k/sample/opera.dwf"
end if
end function
</script>
<code_end>
4. Now I'm adding the action handlers for the buttons to finish it up.
You can use changeDwf() and changeDwf2() interchangeably.
<code_begin>
<INPUT type="button" id=button1 onclick="changeDwf(Whip1, 1)"
value="Show colorwh.dwf" name=button1>
<INPUT type=button id=button2 onclick="changeDwf(Whip1, 2)"
value="Show opera.dwf" name=button2>
<code_end>
Notice how the parameters are passed into the function changeDwf() and
changeDwf2().
** COMPUTERCOORDINATE()
Question:
There is a Whip control interface method ComputeCoordinate() which has a
return value VARIANT? What does it contain?
Answer:
In C++, this is the signature of the method,
VARIANT CWhip::ComputeCoordinate(long from_space, long to_space, double x, double y);
The return type VARIANT, is a VARIANT of type SAFEARRAY, an array of two
doubles that represent the converted points.
All the other parameters of the method are [in] parameters.
The following code snippet shows how to extract the double array. Notice
that it is used for a 3d point but ComputeCoordinate() is returning a
2d point.
// for a 2d point, declare the parameter as pt[2]
// and check the safearray bounds by 2 as well
//
HRESULT getDblArrayFromVariant(double pt[3], const VARIANT* pVal)
{
if (!(pVal->vt & VT_ARRAY && pVal->vt & VT_R8))
return E_INVALIDARG;
SAFEARRAY* sPt = pVal->parray;
if (SafeArrayGetDim(sPt) != 1)
return E_INVALIDARG;
long lLbound;
long lUbound;
SafeArrayGetLBound(sPt, 1, &lLbound);
SafeArrayGetUBound(sPt, 1, &lUbound);
if ((lUbound - lLbound + 1) != 3)
return E_INVALIDARG;
HRESULT hr;
// compare i to 2 for a 2d point
for (long i = 0; i < 3; i++)
if ((hr = SafeArrayGetElement(sPt, &i, &pt))!=S_OK)
return hr;
return S_OK;
}
4 - New or Updated Solutions
----------------------------
16832: CREATING AN ARX ACTIVEX SERVER APPLICATION
/cgi-bin/solution.pl?SID=16832
30524: HOW TO CREATE A SELECTION SET IN VBA USING SELECTBYPOLYGON
/cgi-bin/solution.pl?SID=30524
42014: SELECT FILE WITH STARDARD FILE OPEN DIALOG OF AUTOCAD
/cgi-bin/solution.pl?SID=42014
42345: TRANSLATE DWG COORDS TO SCREEN COORDS
/cgi-bin/solution.pl?SID=42345
45042: HOW TO LOCATE A MENUITEM IN AN ACAD MENU
/cgi-bin/solution.pl?SID=45042
45177: GETTING COORDINATES FOR THE CORNERS OF A VIEWPORT
/cgi-bin/solution.pl?SID=45177
45307: HOW DO YOU RUN THE ACADSTARTUP PROCEDURE WHEN AUTOCAD STARTS?
/cgi-bin/solution.pl?SID=45307
46544: TROUBLE USING VOLOVIEW OCX CONTROL IN ARX
/cgi-bin/solution.pl?SID=46544
46547: CLOSE ALL DOCUMENTS
/cgi-bin/solution.pl?SID=46547
46549: ELLIPSIS BUTTON IN PROPERTIES WINDOW
/cgi-bin/solution.pl?SID=46549
47182: GET IMAGE CLIP BOUNDARY COORDINATES
/cgi-bin/solution.pl?SID=47182
-----------------------------------------------------------------------------
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 |
|