Minggu, 27 Februari 2011

Knowledge detail

About ZRX

Q: How is progress coming along for ZRX?
A: ZRX is a new application programming interface(API) that is similar to ARX.As one of the most powerful APIS in ZWCAD, ZRX enables developers to directly access DWG database, customize entities and migrate their ARX applications to ZWCAD quickly.

Minggu, 20 Februari 2011

Knowledge detail

About SDS

Q: What is SDS, and what can I do with it?
A: SDS is an acronym for “Solutions Development System,” a C/C++ language interface compatible with the ADS® (AutoCAD® Development System) interface found in other CAD systems. SDS provides hooks into ZWCAD, allowing you to create custom applications.
SDS communicates with the user and ZWCAD via LISP akin to the way that ADS works with AutoLISP in other CAD systems. However, SDS greatly augments the capabilities of LISP with a more powerful command base that also accesses the operating system. This allows you to create more sophisticated custom solutions. And because SDS applications are compiled, they are run typically many times faster than any LISP application.
Issue: SDS development environment
Q: How do I configure the development environment when work with the SDS API?
A: SDS is strictly a C/C++ SDK, and so it can be used directly by a standard VC (Visual C) object; you do not need to configure the development environment specially for an SDS application. In other words, you can use the Wizard embed in VC++ compiler to generate a VC object automatically for a SDS application.
The SDS application is built as a DLL file, and the entry point of the DLL file is defined as show below:
void __declspec(dllexport) SDS_EntryPoint(HWND hWnd)
{
   AFX_MANAGE_STATE(AfxGetStaticModuleState());        
   SDS_main(1, &ads_argVec);
    return;
}

Rabu, 16 Februari 2011

Knowledge detail

Migrating VBA

Q: Is it possible to migrate my VBA applications from AutoCAD to ZWCAD?
A: Yes, of course! VBA is designed to be portable between applications. But you will need to make some modifications before migrating the code, which can be done with global search and replace. The changes are as follows:

1. Replace “thisdocument” with “thisdrawing”.
2. All the object names with the prefix of “acad” must be changed to “zwcad”. For example, change “acadLine” to “zwcadLine” and change “acadArc” to “zwcadArc”.
3. The head of the enumeration must be changed from “Ac” to “zc”. For example, change the enumeration about HATCH as follows:
• Change “AcHatchStyle” to “zcHatchStyle”
• Change “AcHatchStyleIgnore” to “zcHatchStyleIgnore”
• Change “AcHatchStyleNormal” to “zcHatchStyleNormal”
• Change “AcHatchStyleOuter” to “zcHatchStyleOut”
Note that there are two special enumerations:
• Change “ACAD_COLOR” to “ZcCOLOR”
• Change “ACAD_LWEIGHT” to “ZCLINEWEIGHT”
4.There is no “Objectname” or “Objecttype” property in this version of ZWCAD. Instead, use “Entityname” and “Entitytype”. If the object is an entity, you can replace them; otherwise, use the “name” property.
Note that it is best to use “Entitytype” if the object has this property, because the name of the object may change in future releases.
5. AutoCAD uses arrays to store points, but ZWCAD defines points as objects, as shown in the following sample code:
Dim PointObj as new Zwcadpoint ‘Must use the NEW function
‘The same mode in AutoCAD and ZWCAD
PointObj(0) = 1
PointObj(1) = 1
PointObj(2) = 1
‘Another mode in ZWCAD
PointObj.x=1
PointObj.x=1
PointObj.x=1
If you want to get a point from user, you must use the SET function, because point is an object. Here is a sample piece of code:
Set PointObj = ThisDocument.Utility.GetPoint(, vbCrLf & “Please choose a point: ”)
When you need to deal with many points, AutoCAD uses array, but ZWCAD uses the “zwcadpoints” class, as illustrated by this sample code:
Dim points as new zwcadpoints ‘Must use NEW to built a list
Dim point as new zwcadpoint
Set point = points.add(x, y, z, item)
5. AutoCAD’s 3dvector is defined as an array, but in ZWCAD it is named “zwcadVector”. It is an object in ZWCAD, so you must to create it with the NEW and SET functions. Here is an example:
‘Define points and vector
Dim Spline as zwcadspline
Dim Points as zwcadpoints
Dim pointObj as new zwcadpoint
Dim startVector as new zwcadVector
Dim endVector as new ZwcadVector
‘Set points
Set PointObj = Points.Add(0, 0, 0, 0) 
Set PointObj = Points.Add(1, 5, 0, 1)
Set PointObj = Points.Add(9, 10, 0, 2)
‘Set vector
startVector.x = 0.5
startVector.y = 0.5
startVector.z = 0
endVector.x = 0.5
endVector.y = 0.5
endVector.z = 0
‘Drawing a SPLINE
Set splineObj = ThisDocument.ModelSpace.AddSpline(Points, startVector, endVector)