Jump to content
Developer Wiki and Function Reference Links ×

callout tool


beanus

Recommended Posts

is it possible to create a script so that when I use the callout tool it's automatically inserted into a class called "notes" if so can someone do this for me, I've tried looking at the Marionette tool just can't get my head around the way it works. 😱

Link to comment

This script will set the class to what is inside the quotes of Const MyClass='None'. Change the None to whatever class name you want.

 

It will not place just the callout in that class, but will change the active class of the drawing to the callout class.

 

I may be able to work around that later (or someone else may pop up first).

 

Not a Marionette solution, but quick and dirty.

 

Procedure ClassedCallout;

{March 30, 2021}
{©2021 Patrick Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}

{No Warranty Expressed of Implied. Use at your own risk.}

Const	MyClass='None';

Var	S1: String;
	B1: Boolean;

Begin
	S1:=ActiveClass;
	NameClass(MyClass);
	B1:=CallToolByName('Callout Tool');
End;

Run(ClassedCallout);

 

Link to comment

Another possible solution is this script, which will place all Callout objects in the drawing into the class specified by the MyClass constant similar to Pat's script above.  You can run this before publishing to catch any callouts that got missed.

 

PROCEDURE SetCalloutClass;

{Sets all Callout objects in drawing to class set by MyClass variable}

CONST

	MyClass = 'Notes';
	
PROCEDURE SetTheClass(h:HANDLE);

	BEGIN
		SetClass(h,MyClass);
	END;
	
BEGIN
	ForEachObject(SetTheClass,(INSYMBOL & INOBJECT & INVIEWPORT & (R IN ['Callout'])));
END;

Run(SetCalloutClass);

 

To add this to a drawing, in the Resource Manager, right-click and select New Resource.  Select Script from the menu.  If this is the first script in the drawing, it will ask you to specify a Script Palette, this can be whatever you want to call it.  "Macros" for example.  Then name the script.  I named mine "Set Callout Class."  A text editor window should open up.  Make sure that the language specified by the drop-down is set to "Vectorscript" and copy and paste the code in and click OK at the bottom of the dialog.  This should now appear in a floating palette and can be run by double-clicking the named script.

 

If you want to make this a more permanent part of your Vectorworks application, you can change it to a menu command using the Plug-in Manager, found under the Tools menu.

 

Unfortunately, there isn't a way to specify a class for plug-in objects unless that plug-in object has a "Style" attached to it, which the standard Callout object does not.

  • Like 2
Link to comment

@beanus Pat's code above could actually work beautifully for that.  It is a little tricky to get it set up if you haven't done it before, but I'll list the steps below.

  1. Open up the Plug-in Manager by going to Tools  - Plug-ins - Plug-in Manager
  2. Select the "Custom Plug-ins" tab
  3. Click on the "New" button at the bottom of the dialog
  4. Select either "Tool" or "Menu Command."  Tool will place it in a tool set (where the Callout Tool regularly resides), Menu Command will make it a command reached through the main menu toolbar
  5. Name the tool/command.  Could be something like "Notes Callout" or something like that
  6. If the script editor window doesn't launch automatically, click on the "Edit Script" button
  7. Copy and paste Pat's script into the editor and click "OK" (but do make sure you set the constant to "Notes" or whatever class you want first)
  8. Click "OK" to close the Plug-in Manager.  Depending on which version of VW you are using, it might prompt you to restart VW.
  9. Open up the Workspace Editor by going to Tools - Workspaces - Edit Current Workspace
  10. Select either the Tools or Menus tab based on which option you selected earlier.
  11. In the left box, scroll down until you find the "Miscellaneous" category and expand it
  12. In the right box, find either the tool set or the menu you want the script to be under and expand it
  13. Click and drag the tool/command from the left box to the right box
  14. Click "OK" to reset your workspace
  15. You're done!

A couple of things to keep in mind: if I were you, I would set it as a menu command and bind the shortcut for the Callout Tool to it.  If you place it as a tool, you'll have to do an additional click to start the tool (one click to select it from the tool set, another click on the drawing to activate).

 

The one caveat to this is that running the tool/command will set your active class to whatever class you set.  Pat's script DOES record the active class when running the tool, but I don't know if there is a way for the tool to detect when the tool is "finished" to restore to the active class, Pat might have some ideas.

  • Like 2
Link to comment

Is there a way of making a similar tool that would move a selected object into a class (in this case Site DTM Modifiers) without changing the active class?

 

I am using 3D poly modifiers and it's very time consuming to scroll dow through the list each time.

 

Custom tool used to do things like this without any programming knowledge a long time ago.

 

Thanks

 

Laura

Link to comment

@Laura Stone That's really simple.  Below is a code snippet that will move selected objects into the class set by the MyClass constant.  If you put this in a script palette, you could have multiple copies set for different classes.  I could see it saving a decent amount of time if you're moving things to different classes a lot, but have a lot of classes in the drawing (especially in VW2018 before they implemented searchable Class drop-downs).

 

PROCEDURE SetSelectedObjClass;

{Sets all Callout objects in drawing to class set by MyClass variable}

CONST

	MyClass = 'None';
	
VAR

	ActiveLayer:STRING;
	
PROCEDURE SetTheClass(h:HANDLE);

	BEGIN
		SetClass(h,MyClass);
		ResetObject(h);
	END;
	
BEGIN
	ActiveLayer:=GetLName(ActLayer);
	ForEachObject(SetTheClass,((SEL=TRUE) & (L=ActiveLayer)));
END;

Run(SetSelectedObjClass);

This script does assume that you are drafting with View-Layer Options set to Show/Snap and not Show/Snap/Modify.  This script will only work on selected objects on the currently active layer, preventing you from changing classes on something that is selected, but not on the active layer, therefore not "showing" as selected.  If, however, you work with Show/Snap/Modify, then change the ForEachObject line to:

 

ForEachObject(SetTheClass,(SEL=TRUE));

Let me know if you need any help getting this script to work in your drawings.  Not knowing your full use-case, I would suggest keeping it with the drawing in a script palette so that it's easy to change the class name.  If you are intending to use the tool with the same class all of the time and want to bind the script to a keyboard shortcut, follow the steps listed in my last post and make this script part of your VW user folder.

  • Like 1
Link to comment

Great,  thanks Jesse that works perfectly and will save me a whole load of time.

 

Just to make it a bit more complicated, when I do the change manually it gives me an option to change all attributes to the new class defaults, it that something that could be written into the script?

 

Laura

 

Link to comment

I can absolutely add that functionality in.  Quick question, so you prefer to have your attribute settings to be set By Class or to use the Use at Creation method but otherwise leave the graphic attributes as absolute?  I can go to ways with this, I can add lines of code to set all the attributes of the selected items to be By Class, or I can read in the class defaults and set the graphic attributes accordingly.

Link to comment

Hi Jesse,

 

Thanks very much, I would like this option please -  "add lines of code to set all the attributes of the selected items to be By Class"

 

I don't normally have 2D attributes by class (it is only fill and pen attributes that I need here) it's just quite handy to have the site modifiers by class, then I can see which ones I've finished.

 

Laura

 

 

Link to comment

Here you go.  The script will now set all attributes to be "By Class."  Each line is notated with what the attribute is, so if there are attributes you don't want to set (like Marker or Line Weight), just delete those lines.  If you would rather set the objects to use the defaults of the class without the "By Class" reference, let me know and I'll adjust the code.

 

PROCEDURE SetSelectedObjClass;

{Sets all Callout objects in drawing to class set by MyClass variable}

CONST

	MyClass = 'None';
	
VAR

	ActiveLayer:STRING;
	
PROCEDURE SetTheClass(h:HANDLE);

	BEGIN
		SetClass(h,MyClass);
		
		{Attributes settings}
		SetFPatByClass(h);			{Fill Pattern}
		SetFillColorByClass(h);		{Fill Color}
		SetLSByClass(h);			{Line Type}
		SetPenColorByClass(h);		{Pen Color}
		SetLWByClass(h);			{Line Weight}
		SetOpacityByClass(h);		{Opacity}
		SetMarkerByClass(h);		{Marker}
		
		ResetObject(h);
	END;
	
BEGIN
	ActiveLayer:=GetLName(ActLayer);
	ForEachObject(SetTheClass,((SEL=TRUE) & (L=ActiveLayer)));
END;

Run(SetSelectedObjClass);

 

Link to comment
  • 5 months later...

Hi There!

I'm new in this forum and new to scripting. I've found Pat Stanfords script very useful but I'would like to rstore the ActiveClass and modified the script like that:

 

Quote

 

Procedure ClassedCallout;

Const    MyClass='060-Beschriftung';
        MyFont=130;
        MyFontSize=10;

Var    S1: String;
    B1: Boolean;
    
Begin
    S1:=ActiveClass;
    NameClass(MyClass);
    TextFont(MyFont);
    TextSize(MyFontSize);
    TextFace([]);
    B1:=CallToolByName('Callout Tool');
    DSelectAll;    
    NameClass(S1);
End;

Run(ClassedCallout);

 

 

but it doesn't work - the callout is still selected and the former active class is asigned. As Jesse Cogswell allready mentioned it looks like the script doesn't know when the tool is finished. I also tried PushAttrs/PopAttrs with the same solution...

Can Anybody help? 

Link to comment

That script will:

 

store the name of the active class

make 60-Beschriftung the active class

set the text font, size, and face

make the callout tool active 

deselect any selected objects on the active layer

restore the original class

 

This will look like nothing happened 😎

 

Are you trying to change the class assignment of existing callouts? (If so @Jesse Cogswellhas a script in this thread above that does exactly that!)

Link to comment

You either have to use a second script to set the class back or you have to include the code to insert the callout inside the script. 

 

There is nothing in VS that will let you pause a script, allow the user to do something, and then restart the script.

 

Something like:

 

   Hand:=CreateCustomObject('Callout', 0, 0, 0);

 

And then use the SetObjectVariable options to make the settings of the callout what you want.

 

Ask again if you need more help.

Link to comment

@Pat Stanford Thanks for your input.

 

I don't understand why this works with the polyline tool:

 

Quote

Procedure CustTool;
VAR 
Name:STRING;
Result:BOOLEAN;
BEGIN 
PushAttrs;
NameClass('060-Beschriftung');
TextFont(130);
TextSize(10);
TextFace([]);
CallTool(-204);
PopAttrs;
END;
Run(CustTool);

 

This script allows me to draw a polyline on the class 060-Beschriftung and returns to the original active class after finishing the polyline.

When I modify the script with the 'callout tool' it puts the new created  Callout in the active class... 

Link to comment

This will almost do it, but you can see there's more to it than you would think.  I can make the class work, but not the font or font size.  I tried a couple different ways, and you can see the remnants of my attempts in the code.  Maybe if you used a text style and assigned it to the class?

 

 

PROCEDURE Test;

CONST
	kCalloutClass 	=	'060-Beschriftung';
	kTextFont		=	'Times New Roman';
	ktextSize		=	'10';
	kTextFace		=	'Plain';
VAR
	H 	: HANDLE;
	S 	: STRING;
	X1,Y1	: REAL;
BEGIN
	PushAttrs;
	NameClass(kCalloutClass);

	TextFont(130);
	TextSize(10);
	TextFace([]);
	
	GetPt(X1,Y1);
	S := StrDialog('Callout Text:','Enter callout text');
	H := CreateCustomObjectN('Callout',X1,Y1,0,FALSE);
		
	Record(H,'Callout');
		SetRField(LNewObj,'Callout','Link To Database','False');
		SetRField(LNewObj,'Callout','Place As Keynote','False');
		SetRField(LNewObj,'Callout','Keynote Prefix','');
		SetRField(LNewObj,'Callout','Keynote Suffix','');
		SetRField(LNewObj,'Callout','BubbWidth','1.999999999999998"');
		SetRField(LNewObj,'Callout','Vertical Placement','Auto');
		SetRField(LNewObj,'Callout','Orientation','Auto');
		SetRField(LNewObj,'Callout','Left','False');
		SetRField(LNewObj,'Callout','Bubble Style','None');
		SetRField(LNewObj,'Callout','Radius Factor','0.046875"');
		SetRField(LNewObj,'Callout','Margin','0.046875"');
		SetRField(LNewObj,'Callout','Bubble Shadow','False');
		SetRField(LNewObj,'Callout','Shoulder','1''0.000000000000002"');
		SetRField(LNewObj,'Callout','Leader Type','Straight');
		SetRField(LNewObj,'Callout','Leader Style','Line');
		SetRField(LNewObj,'Callout','LineLength','11''10.403037186711714"');
		SetRField(LNewObj,'Callout','__ShowDialog','False');
		SetRField(LNewObj,'Callout','Rise','0.19"');
		SetRField(LNewObj,'Callout','Text',S);
		SetRField(LNewObj,'Callout','DNE','Solid Arrow\1\-1');
		SetRField(LNewObj,'Callout','TextFont',kTextFont);
		SetRField(LNewObj,'Callout','TextSize',kTextSize);
		SetRField(LNewObj,'Callout','TextStyle','Plain');
		SetRField(LNewObj,'Callout','ControlPoint01X','-1''6.072916666666661"');
		SetRField(LNewObj,'Callout','ControlPoint01Y','-3''11.36458333333335"');
		SetRField(LNewObj,'Callout','ControlPoint02X','-6''4.177083333333329"');
		SetRField(LNewObj,'Callout','ControlPoint02Y','-4''11.385416666666693"');
		SetRField(LNewObj,'Callout','ControlPoint03X','1''0.000000000000002"');
		SetRField(LNewObj,'Callout','ControlPoint03Y','0"');
		SetRField(LNewObj,'Callout','ControlPoint04X','9''0.046874999999915"');
		SetRField(LNewObj,'Callout','ControlPoint04Y','0"');
		SetRField(LNewObj,'Callout','__dbName','');
		SetRField(LNewObj,'Callout','__dbUUID','');
		SetRField(LNewObj,'Callout','__NoteUUID','{3A2C49CF-A276-45EC-9CA5-874C740D23EF}');
		SetRField(LNewObj,'Callout','__NoteDescrip','This is a test');
		SetRField(LNewObj,'Callout','__KeynoteNumber','0');
		SetRField(LNewObj,'Callout','__OldPlaceAs','False');
		SetRField(LNewObj,'Callout','__OldBubbWidth','1.999999999999998"');
		SetRField(LNewObj,'Callout','__OldShoulder','1''0.000000000000002"');
		SetRField(LNewObj,'Callout','__OldLeaderStyle','');
		SetRField(LNewObj,'Callout','__IsFlipped','False');
		SetRField(LNewObj,'Callout','__isNew','False');
		SetRField(LNewObj,'Callout','__version','2500');
		SetRField(LNewObj,'Callout','__markerCode','1;0;15;0.125000;0.000000;2;0.050000;');
		SetRField(LNewObj,'Callout','Arrow Style','Solid Arrow');
		SetRField(LNewObj,'Callout','Marker Symbol','Arrowhead 1');
		SetRField(LNewObj,'Callout','Marker Scale Factor','0.125"');
		SetRField(LNewObj,'Callout','MarkerAng','15');
		SetRField(LNewObj,'Callout','Marker Weight','10');
		SetRField(LNewObj,'Callout','__OldCtrlPt03X','304.8');
		SetRField(LNewObj,'Callout','__OldCtrlPt03Y','0');
		SetRField(LNewObj,'Callout','__OldCtrlPt04X','2744.390625');
		SetRField(LNewObj,'Callout','__OldCtrlPt04Y','0');
		SetRField(LNewObj,'Callout','Keynote Legend','Default Legend');
		SetRField(LNewObj,'Callout','__OldKeynoteLegend','Default Legend');
		SetRField(LNewObj,'Callout','Leader Radius','0"');
		SetRField(LNewObj,'Callout','OldText','This is a test');
		SetRField(LNewObj,'Callout','__IsUseReletivePath','False');
		SetRField(LNewObj,'Callout','__DBReletivePath','');
		SetRField(LNewObj,'Callout','Text Angle','0.00°');
		SetRField(LNewObj,'Callout','Rotate Text','False');
		SetRField(LNewObj,'Callout','__OldTextAngle','0.00°');
		SetRField(LNewObj,'Callout','__BubbleShadowPenColor','-3');
		SetRField(LNewObj,'Callout','__BubbleShadowFillColor','-3');
		SetRField(LNewObj,'Callout','HorizontalTextAlignment','Auto');
		SetRField(LNewObj,'Callout','New Bubble Style V20','None');
		SetRField(LNewObj,'Callout','New Vertical Placement','Auto');
		SetRField(LNewObj,'Callout','Draw Extended Shoulder','False');
		SetRField(LNewObj,'Callout','Text Style Ref','0');
		SetRField(LNewObj,'Callout','Text Spacing Index','2');
		SetRField(LNewObj,'Callout','Text Spacing Value','0');
		SetRField(LNewObj,'Callout','Leader Angle','-131.44°');
		SetRField(LNewObj,'Callout','__ObjectRotationAngle','0');
		SetRField(LNewObj,'Callout','__DrawTwoSoulders','False');
		SetRField(LNewObj,'Callout','__LeadingLeaderPointX','0');
		SetRField(LNewObj,'Callout','__LeadingLeaderPointY','0');
		SetRField(LNewObj,'Callout','__SecondaryLeaderPointX','1764.69278125');
		SetRField(LNewObj,'Callout','__SecondaryLeaderPointY','0');
		SetRField(LNewObj,'Callout','ControlPoint05X','4''9.47609374999999"');
		SetRField(LNewObj,'Callout','ControlPoint05Y','0"');
		SetRField(LNewObj,'Callout','__OldSecondaryShoulderPointX','1459.89278125');
		SetRField(LNewObj,'Callout','__OldSecondaryShoulderPointY','0');
		SetRField(LNewObj,'Callout','__LeaderLinesData','{
			"handles" : [
				{
					"index" : 1,
					"firstPtIndex" : 1,
					"lastPtIndex" : 4,
					"leaderType" : 0
				}		
						]
				}');
		SetRField(LNewObj,'Callout','__CustomPointsData',Concat('{
			"handles" : [
				{
					"index" : 1,
					"type" : 1,
					"x" : 0,
		','			"y" : 0,
					"bezier" : false
				},
				{
					"index" : 2,
					"typ','e" : 2,
					"x" : -2393.9499999999998181,
					"y" : -2711.44999999','99998181,
					"bezier" : false
				},
				{
					"index" : 3,
					"type"',' : 4,
					"x" : -459.05208333333314386,
					"y" : -1203.0604166666','669244,
					"bezier" : true
				},
				{
					"index" : 4,
					"type" : ','5,
					"x" : -1934.8979166666665606,
					"y" : -1508.3895833333340','306,
					"bezier" : true
				}
			]
		}'));
		SetRField(LNewObj,'Callout','Max Leader Lines','2');
		SetRField(LNewObj,'Callout','__ActiveSubObject','4');
		SetRField(LNewObj,'Callout','__SubObjectDataAttributes',Concat('{
			"handles" : [
				{
					"index" : 1,
					"objectType" : 1,
					"hi','ghlightingObject" : false,
					"objectPenStyle" : 1,
					"objectCl','assPenStyle" : 1,
					"objectPenPatternIndex" : 2,
					"objectPenP','atternForeColor" : 257,
					"objectPenPatternBackColor" : 256,
				','	"objectPenColor" : 257,
					"objectPenLineType" : 2,
					"objectP','enLineTypeName" : "",
					"objectThickness" : 2,
					"objectMarker','Style" : 0,
					"objectMarkernAngle" : 15,
					"objectMarkerdSize"',' : 0.125,
					"objectMarkerdWidth" : 0,
					"objectMarkernThicknes','sBasis" : 2,
					"objectMarkerdThickness" : 0.0500000000000000027','76,
					"objectOpacity" : 100,
					"penColorByClass" : false,
					"','thicknessByClass" : false,
					"markerByClass" : false,
					"opaci','tyByClass" : false
				},
				{
					"index" : 2,
					"objectType" : 2,','
					"highlightingObject" : false,
					"objectPenStyle" : 1,
					"o','bjectClassPenStyle" : 1,
					"objectPenPatternIndex" : 2,
					"obj','ectPenPatternForeColor" : 257,
					"objectPenPatternBackColor" : ','256,
					"objectPenColor" : 257,
					"objectPenLineType" : 2,
					"','objectPenLineTypeName" : "",
					"objectThickness" : 2,
					"objec','tMarkerStyle" : 0,
					"objectMarkernAngle" : 15,
					"objectMarke','rdSize" : 0.125,
					"objectMarkerdWidth" : 0,
					"objectMarkernT','hicknessBasis" : 2,
					"objectMarkerdThickness" : 0.050000000000','000002776,
					"objectOpacity" : 100,
					"penColorByClass" : fals','e,
					"thicknessByClass" : false,
					"markerByClass" : false,
				','	"opacityByClass" : false
				},
				{
					"index" : 3,
					"objectTyp','e" : 3,
					"highlightingObject" : false,
					"objectPenStyle" : 1',',
					"objectClassPenStyle" : 1,
					"objectPenPatternIndex" : 2,
		','			"objectPenPatternForeColor" : 257,
					"objectPenPatternBackCo','lor" : 256,
					"objectPenColor" : 257,
					"objectPenLineType" : ','2,
					"objectPenLineTypeName" : "",
					"objectThickness" : 2,
		','			"objectMarkerStyle" : 0,
					"objectMarkernAngle" : 15,
					"obje','ctMarkerdSize" : 0.125,
					"objectMarkerdWidth" : 0,
					"objectM','arkernThicknessBasis" : 2,
					"objectMarkerdThickness" : 0.05000','0000000000002776,
					"objectOpacity" : 100,
					"penColorByClass"',' : false,
					"thicknessByClass" : false,
					"markerByClass" : fa','lse,
					"opacityByClass" : false
				},
				{
					"index" : 4,
					"ob','jectType" : 4,
					"highlightingObject" : false,
					"objectPenSty','le" : 1,
					"objectClassPenStyle" : 1,
					"objectPenPatternIndex','" : 2,
					"objectPenPatternForeColor" : 257,
					"objectPenPatter','nBackColor" : 256,
					"objectPenColor" : 257,
					"objectPenLineT','ype" : 2,
					"objectPenLineTypeName" : "",
					"objectThickness" ',': 2,
					"objectMarkerStyle" : 0,
					"objectMarkernAngle" : 15,
			','		"objectMarkerdSize" : 0.125,
					"objectMarkerdWidth" : 0,
					"','objectMarkernThicknessBasis" : 2,
					"objectMarkerdThickness" : ','0.050000000000000002776,
					"objectOpacity" : 100,
					"penColorB','yClass" : false,
					"thicknessByClass" : false,
					"markerByClas','s" : false,
					"opacityByClass" : false
				}
			]
		}'));
		SetRField(LNewObj,'Callout','__KeynotesListUpdate','False');
		SetRField(LNewObj,'Callout','TextSizePagePoints','12.000000');
		SetRField(LNewObj,'Callout','Auto Fit Bubble Width','True');
		SetRField(LNewObj,'Callout','Max Bubble Width','1.999999999999998"');
		SetRField(LNewObj,'Callout','Keynote Identifier','0');
		SetRField(LNewObj,'Callout','__OldKeynoteIdentifier','0');
		SetRField(LNewObj,'Callout','__IsNoteUpdated','True');
		SetRField(LNewObj,'Callout','__UseFirst42','True');
		
	ResetObject(H);
	PopAttrs;
END;	

RUN(Test);

 

I understand what all the normal SetRField functions do, but I have no idea what the crazy ones do.  

 

I've tried deleting a few to see what happens.  The results are amusing, but I just left it all in to make sure it works in a meaningful way.

  • Like 2
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...