How to Add Polish to a Vdraft Add-on |
In Visual Basic:
Dim Commands As Object Set Commands = doc.Commands Commands.Group "Acme.DrawRoom Living Room" ... ' insert blocks, draw lines, etc. Commands.EndGroupIn C++:
ICommands commands(doc.GetCommands()); commands.Group(CString("Acme.DrawRoom Living Room")); ... // insert blocks, draw lines, etc. commands.EndGroup();This code would cause all the commands executed between Group and EndGroup to be lumped together. The first piece of text, Acme.DrawRoom, is the command name. When you click the right button in Vdraft or display the Edit pulldown menu, Undo Acme.DrawRoom will be displayed. In this example, we've added the company name to the name of the command to differentiate it from somebody else's DrawRoom command. (Alternately, you could use the program's name or have no prefix at all.) The rest of the string is the description. It can be whatever information may be useful to the user when they examine the undo/redo list.
The following code snippets will convert the point string 10' 2 1/2", 12' 1.2, 5" and place 122.5, 145.2, 5 into MyVector.
In Visual Basic:
Dim Units As Object, MyVector As Object Set Units = doc.Units ' 10' 2 1/2", 12' 1.2, 5" pointstring$ = "10' 2 1/2" + Chr$(34) + ", 12' 1.2, 5" + Chr$(34) Set MyVector = Units.StringToPoint(pointstring$)In C++:
IUnits units(doc.GetUnits()); IVector MyVector( units.StringToPoint(CString( "10' 2 1/2\", 12' 1.2, 5\"" )) );Users have the option of displaying distances and angles in several different formats. If they have chosen metric with a scaling factor, or architectural with feet and fractional inches, then they would probably prefer to see all output in that format. The following code will create strings using the drawing's current settings.
In Visual Basic:
point$ = Units.PointToString (MyVector) length$ = Units.CoordinateToString (1.234) ' note: specified in drawing units angle$ = Units.AngleToString (3.1415) ' note: specified in radiansIn C++:
CString point( Units.PointToString(MyVector) ); CString length( Units.CoordinateToString(1.234) ); // note: specified in drawing units CString angle( Units.AngleToString(3.1415) ); // note: specified in radians
The following example prompts the user to pick a point. The popup menu will contain the text Cancel Center. On the status bar will be Pick the center of the object. The Visual Basic example uses the VdraftEvents Control. The C++ example derives cMyPickEvent from cPickEvent (defined in Vutil.hpp).
In Visual Basic:
Dim pick As Object Set pick = doc.PickEvents pick.Name = "Center" pick.StatusBar = "Pick the center of the object" VdraftEvents1.RequestPick pick, 0In C++:
IPickEvents pick(doc.GetPickEvents()); pick.SetName(CString("Center")); pick.SetStatusBar(CString("Pick the center of the object")); pick.RequestPick(id,cVariant(new cMyPickEvent(vdraft,id)));The next example asks the user to select objects. The cursor tip will say select objects for manipulation. The popup will contain Cancel Manipulation. Once the user has selected as least one object, the popup will also say Start Manipulation. The status bar will display Select objects for manipulation. In the C++ example, cMySelectEvent is derived from cSelectEvent.
In Visual Basic:
Dim selection As Object Set selection = doc.SelectionEvents selection.Name = "Manipulation" selection.StatusBar = "Select objects for manipulation" VdraftEvents1.RequestSelect selection, 0In C++:
ISelectionEvents selection(doc.GetSelectionEvents()); selection.SetName(CString("Manipulation")); selection.SetStatusBar(CString("Select objects for manipulation")); selection.RequestSelect(id,cVariant(new cMySelectEvent(vdraft,id)));
SoftSource LLC 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 |
---|