Vdraft is built on the newest technology, incorporating true object-oriented design from
its core on out. This gives the add-on developer many advantages, the chief of which is
relatively simple code that is easy to understand - almost self-documenting.
The following code fragments show how you would take the last drawing entity created and change the layer it is on. A simple enough and routine enough chore. The following examples contrast programming for Vdraft versus AutoCAD. Using Visual Basic with Vdraft is readable even by non-programmers. The AutoLisp code is obscure and difficult to interpret. The Vdraft C++ example uses the C++ version of the same API as Visual Basic (e.g. Drawing.GetEntities() instead of Drawing.Entities). The AutoCAD ADS example is even more obscure than AutoLisp.
|
Drawing.Entities.Last.Layer = Drawing.Layers("MYLAYER")AutoLisp for AutoCAD
(setq entity (entget (entlast))) (setq entity (subst (cons 8 "MYLAYER") (assoc 8 entity) entity)) (entmod entity)C++ for Vdraft
IEntities Entities (Drawing.GetEntities()); IEntity LastEntity (Entities.GetLast()); ILayers Layers (Drawing.GetLayers()); ILayer Layer (Layer.GetItem(cVariant("MYLAYER"))); LastEntity.SetLayer(Layer);ADS for AutoCAD
struct resbuf *ent, *ptr; ads_name last; ads_entlast(last); ent = ads_entget(last); ptr = ent; while (ptr != NULL) { if (ptr->restype == 8) { // assumes the string buffer is long enough strcpy(ptr->resval.rstring, "MYLAYER"); break; } ptr = ptr->next; } ads_entmod(ent);
SoftSource 112 Ohio Street Suite 202 Bellingham, Washington 98225 Phone: (360) 676-0999 Sales Only: (800) 877-1875 |
Sales:
sales@softsource.com Tech Support: tech@softsource.com |
---|