.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
DescriptionActivates the specified VectorWorks tool for a single use. After the tool has been used VectorWorks will revert back to the previously active tool.
Note: Please refer to the VectorScript Appendix for specific tool ID values.
def vs.CallTool(toolID): return None
toolID INTEGER VectorWorks tool constant.
RemarksChanges the active tool to that specified by toolID. Waits until the user has executed the functionality of that tool, then switches back to the previously active tool & returns.
I found that if you have a plug-in that uses the CallTool procedure to create an object (specifically a freehand poly) while you are in a group or editing a symbol definition, you cannot get the handle to the poly using the standard functions LNewObj, LSActLayer, LObject or any other I can think of.
I think I found a foolproof (?) solution:
- Create a dummy object and get its handle (dummyH.)
- Implement the CallTool procedure and create the poly.
- Use "polyH := NextObj (dummyH)" to get the handle to the poly.
- Delete the dummy object.
This works in nested groups as well as groups within symbols. If anyone knows of a simpler solution, please let me know.
Another method is to do a DSelectAll at the beginning of the program, and then you should be able to find the last created entity by searching for selected items (ForEachObject(MyProcedure, (SEL=TRUE))), assuming that the object created by the tool is still selected. Depending on what you're doing, this may be simpler, but it's certainly a bit scarier.
If the user drops the tool then no object will be created and NextObj(DummyObj) will be NIL.
PROCEDURE Example; VAR h1, h2, h3 :HANDLE; int :INTEGER; BEGIN DSelectAll; BeginXtrd(0, 1); CallTool(-203); h1 := FSActLayer; EndXtrd; DSelectAll; BeginXtrd(0, 1); CallTool(-203); h2 := FSActLayer; EndXtrd; int := AddSolid(h1, h2, h3); END; RUN(Example);
PROCEDURE AddSurfaceExample; VAR h1, h2, h3 :HANDLE; BEGIN DSelectAll; CallTool(-203); h1 := FSActLayer; DSelectAll; CallTool(-203); h2 := FSActLayer; h3 := AddSurface(h1, h2); IF h3 <> NIL THEN SetFPat(h3, 5); END; RUN(AddSurfaceExample);
def Example(): vs.DSelectAll() vs.CallTool(-203) h1 = vs.FSActLayer() vs.DSelectAll() vs.CallTool(-203) h2 = vs.FSActLayer() h3 = vs.AddSurface(h1, h2) if h3 != None : vs.SetFPat(h3, 5) Example()
PushAttrs; PenFore(16); PenBack(0); PenPat(-2); CallTool(-201); PopAttrs;