VS:CallTool

From Vectorworks Developer
Revision as of 10:25, 12 August 2013 by Root (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Activates 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.

PROCEDURE CallTool(
toolID  :INTEGER);
def vs.CallTool(toolID):
    return None

Parameters

toolID INTEGER VectorWorks tool constant.

Remarks

Changes 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:

  1. Create a dummy object and get its handle (dummyH.)
  2. Implement the CallTool procedure and create the poly.
  3. Use "polyH := NextObj (dummyH)" to get the handle to the poly.
  4. 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.

Example

VectorScript

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);

Python


VectorScript

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);

Python

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;

Python


Version

Availability: from MiniCAD4.0
Personal tools
NamespacesFFFF

Variants
Actions
Advanced Search
See Also
Navigation
Toolbox