Jump to content

Changing dimension text size within a vectorScript


ClockWerX

Recommended Posts

Hello Everyone,

Can you help me with the following problem.

We use VectorWorks 9.5.1 on a Mac. I like to change the textsize of a dimension (height and width of an object) within a VectorScript.

This is the situation :

First the objects are drawed.

Then the dimensions of the objects are placed in the document.

Then the script will be running who has to change the text height of the used font in another height.

When I manually select a dimension (line + text) I can change the textsize inside the fonts menu.

However when I select the same dimension with a script I do not succeed in changing the text height.

Can you tell me how I can accomplish to change the text size of a dimension?

Your input will be highly appreciated.

I wish you all the best and have a nice day.

Friendly greetings,

Chrissy

Link to comment

Well, as is usually the case, confusion clears as I walk away from a problem. I was confused as to why text was grouped inside a dimension object, but I was only thinking of the single numeric object that represents the dimension length.

In a simple dimension, there is only one text object within the dimension object, the length of the dimension. It seemed unnecessary to group it. However, dimensions can be made more complicated by adding tolerances, leaders and/or trailers in the OIP. Each of these text objects can also be found inside the group within the dimension object, if they exist.

So, once you have a handle to the first text object within a dimension object, you may have to search for additional text objects to format. The number of text objects can be determined by the setttings in the OIP that control the dimension object. I hope this makes sense to you.

Have fun,

Raymond

Link to comment

Hi Chrissy,

Depending on the level of control you desire, there are two ways I know of to do what you ask.

The easiest is to use DoMenuTextByName. If you can use one of the point sizes in the menu, just put it's menu index in the following call.

DoMenuTextbyName('Font Size', 4); { 12 points }

For more complicated processing, you can get a handle to the text element of a dimension object using something similar to the following:

code:

procedure xxx;

CONST

TextType = 10;

GroupType = 11;

VAR

H :Handle;

BEGIN

H := FIn3D(FSActLayer);

while ((H<>nil) & (GetType(H)<>TextType)) do begin

if (GetType(H)=GroupType) then H := FIn3D(H) { Text is grouped, don't know why }

else H := NextObj(H);

end;

if (H<>nil) then begin

Message(H, ' ', GetType(H));

{ You have a handle to the text part of the Dimension }

{ insert your code here }

end;

END;

Run(xxx);
[/code]

Have fun,

Raymond

Link to comment

Hello again Chrissy,

As I rode my horse around the pasture today, in the last light of the setting sun (a national pastime in Texas), I gained some more clarity to your problem. If you don't want to use the DMTBN approach, the following procedure will find all the text objects in a dimension object, regardless of how they are nested in groups. Actually, the code will work for any nested group of objects, not just dimensions. I leave it to you to do with them as you will.

I always enjoy writing recrusive routines, perhaps because I don't get to use them much. So, here's one that was fun to write.

code:

procedure xxx;

{ Get the handles to all text objects within a dimension object. }

{ Author : Raymond J Mullin - ?2004 All rights reserved. }

CONST

TextType = 10;

GroupType = 11;

VAR

H :Handle;

procedure FindTxtObj(H :Handle);

{ Receive a handle to a container object. Step in, and look for Text objects. }

Begin

H := FIn3D(H);

while (H<>nil) do begin

case GetType(H) of

TextType: begin { Do stuff to text here }

Message(H, ' ', GetType(H), ' ', GetText(H));

Wait(1);

end;

GroupType: FindTxtObj(H); { Re-enter this procedure and search the new group. }

end; { case }

H := NextObj(H);

end; { while }

End; { FindTxtObj }

BEGIN

ClrMessage;

H := FSActLayer; { Handle to Dimension Object }

FindTxtObj(H);

Sysbeep;

END;

Run(xxx);
[/code]

Link to comment

Hello Raymond,

Thank you very much for your very clear explanations. Indeed the dimension consist of one simple text object. Only a number who shows the length or widht of the object..

I will experiment with both methods to see which works best for us.

People who are working with VectorWorks at that company use the option "no fill behind a text". However when they put a dimension on an object, the number is centered vertically on the dimension base line. So the line is visible on the dimension. Therefore I created a script (years ago) which activate the background again on every dimension on the drawing. I added the shortcut "ctrl" + "," to that PIO. So it is my intention to insert your procedure in the existing code.

I will add your copyright notices on every procedure which contain your code and also put our copyright notices on the beginning of the script. When the complete script is ready I will put a copy of the code here on this post.

Thank you very much for your help which is very appreciated. I wish you a very nice day and all the best.

You are a very helpfully person.

Friendly greetings,

Chrissy

Link to comment
  • 11 years later...

Chrissy,

How did you get this to work?

I added SetTextSize (h, 0, 99, GetTextSize (h, 1) / GetLScale (ActLayer) * 25); after the message.

This changes the text visually on the screen, but not really. If you cut and past the dimension, it shows the original text size.

I think we want the same thing for different reasons.

I've written a macro to change all layers of the same scale as the active layer to a new asked scale. The problem is the text doesn't stay the same point size after the layer changes scale and the code that Raymond wrote (with my addition above)  changes the text only visually.

 

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