Jump to content
Sign in to follow this  
James Russell

Help with Tool Creation

Recommended Posts

Hi all,

I'm trying to create a new tool for use in our new template. I've been playing with the create custom tool scripts for a while but I am not able to get the result that I want at the moment.

Basically I would like a tool that creates a double line polygon with three components, 30mm as the overall width, broken into two fills, a black fill for 20mm and a 10mm fill in red, see attached pic for details on that part. Using the existing custom create a tool I have this script:

Procedure CustTool;

VAR

Name:STRING;

Result:BOOLEAN;

BEGIN

PushAttrs;

Result := DeleteAllDLComponents;

Result := InsertNewDLComponent(1, 20, 1, 0, 2, 2, 2);

Result := SetDLComponentName(1, 'BLACK');

Result := SetDLComponentClass(1, 0);

Result := SetDLComponentFillColors(1, 257, 257);

Result := SetDLComponentPenColors(1, 257, 256, 257, 256);

Result := SetDLComponentUseFillClassAttr(1, FALSE);

Result := SetDLComponentUsePenClassAttr(1, FALSE, FALSE);

Result := InsertNewDLComponent(2, 10, 1, 2, 0, 2, 2);

Result := SetDLComponentName(2, 'RED');

Result := SetDLComponentClass(2, 0);

Result := SetDLComponentFillColors(2, 257, 1251);

Result := SetDLComponentPenColors(2, 257, 256, 257, 256);

Result := SetDLComponentUseFillClassAttr(2, FALSE);

Result := SetDLComponentUsePenClassAttr(2, FALSE, FALSE);

SetDLSeparation(30);

SetDLControlOffset(0);

SetDLOptions(1);

CallTool(-218);

CallTool(-218);

PopAttrs;

END;

Run(CustTool);

This works very well for the first part of my little project. The resultant is 3 polygons (as expected), black, red and white. Now for the tricky part.

On completion of drawing the polygons I would like it to select the white polygon and convert it into a Lighting Position Object.

Anyone? It's probably a line like get selected object white convert to lighting position object, but I really don't know the syntax on that.

Any help much appreciated.

Cheers,

James

Share this post


Link to post

First of all, why do you use CallTool(-218); two times? I think one is enough.

You can use this at the end of your script:

	DSelectAll;
h:=PrevObj(PrevObj(LObject));
SetSelect(h);

h is the handle to that "base" poly. SetSelect(h) makes sure that that poly is selected after execution.

I have no idea what a Lighting Position Object is (i have a Dutch translation of VW) and can't find it in the menus, so maybe somebody else know a way to Convert it?

Share this post


Link to post

BTW, the small component isn't red on my computer, probable because "1251" is not a standard color...

Result := SetDLComponentFillColors(2, 257, 1251);

If you need to use this on other computers too, i think its safer to use "7" for red, that's the standard color and will normally work on every drawing.

Result := SetDLComponentFillColors(2, 257, 7);

Share this post


Link to post

Maarten,

Thankyou, you are correct, twice was the generated output from the custom tool creation script, and the colour was just something I chose from the palette at random.

I placed:

DSelectAll;

h:=PrevObj(PrevObj(LObject));

SetSelect(h);

after the Popattrs; and added h:Handle; to the VAR as I thought it should go but once the double polygon is finished being drawn all three polygons are still selected.

Even if I can just look within these three polygons for the one where pen colour=null and that becomes selected. The Convert to Lighting Position Object could be a manual menu job if necessary.

I'll keep playing but any input is much appreciated.

Cheers,

James

Edited by James Russell

Share this post


Link to post

Converting to a Lighting Position Object completely by script is not so straight forwards. I can outline the method, but first give DoMenuTextByName a try using Spotlight's Convert to Lighting Position menu item. That should work for you and be within your scripting comfort level.

-Josh

Share this post


Link to post

Very strange, i tried it yesterday and it did work, but now i can't seem to reproduce it... I must stop posting things so early in the morning :) .

Oke, here's an other way of doing this:

Procedure CustTool;
VAR
Name:STRING;
Result:BOOLEAN;
tmph,h:HANDLE;
BEGIN
PushAttrs;
Locus(0,0);
tmph:=LNewObj;
Result := DeleteAllDLComponents;
Result := InsertNewDLComponent(1, 20, 1, 0, 2, 2, 2);
Result := SetDLComponentName(1, 'BLACK');
Result := SetDLComponentClass(1, 0);
Result := SetDLComponentFillColors(1, 257, 257);
Result := SetDLComponentPenColors(1, 257, 256, 257, 256);
Result := SetDLComponentUseFillClassAttr(1, FALSE);
Result := SetDLComponentUsePenClassAttr(1, FALSE, FALSE);
Result := InsertNewDLComponent(2, 10, 1, 2, 0, 2, 2);
Result := SetDLComponentName(2, 'RED');
Result := SetDLComponentClass(2, 0);
Result := SetDLComponentFillColors(2, 257, 1251);
Result := SetDLComponentPenColors(2, 257, 256, 257, 256);
Result := SetDLComponentUseFillClassAttr(2, FALSE);
Result := SetDLComponentUsePenClassAttr(2, FALSE, FALSE);
SetDLSeparation(30);
SetDLControlOffset(0);
SetDLOptions(1);
CallTool(-218);
PopAttrs;
DSelectAll;
h:=NextObj(tmph);
DelObject(tmph);
SetSelect(h);
DoMenuTextByName('Convert to NURBS',0);
END;
Run(CustTool);

You need to adjust the last line DoMenuTextByName('Convert to NURBS',0); by something else. I don't have Spotlight so i can't call that menu item. It should be something like DoMenuTextByName('Convert to Lighting Position Object',0);

Share this post


Link to post

Thankyou both or your help, the DoMenuTextByName command is awesome, perfect some would say. The only issue I'm having which feels like a bug is when the convert to light position is done, the object becomes unselectable, try the script below if you have spotlight.

Procedure CustTool;

VAR

Name:STRING;

Result:BOOLEAN;

BEGIN

PushAttrs;

CallTool(-203);

PopAttrs;

DoMenuTextByName('Convert to Light Position',0);

END;

Run(CustTool);

It should let you draw a rectangle and then convert it to a light position. I find I cannot select the object only the label handle. When I touch this or nudge the object it returns to normal.

I tried a Hmove on it by a fraction but to no avail.

Frustratingly close, does anyone else have this?

J

Share this post


Link to post

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.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...