Jump to content
Developer Wiki and Function Reference Links ×

Line Type Functions?


Joe-SA

Recommended Posts

I'm trying to find the functions for Line Type settings. Not Linestyles but Line Types with the repeating graphic in the Resource Browser. I'm not finding anything in the function reference.

I'd like set a custom Line Type to a class and/or set a Line Type to a custom Tool.

It appears the Custom Tool function doesn't recognize active Line Type settings. In an ideal world I would be able to call a Line Type by name and the script would find it in the Resource Browser AND if it wasn't in the browser it would look for it in my Default Line Styles file.

Edited by Joe-SA
Link to comment
  • Vectorworks, Inc Employee

You can build a list of line types using BuildResourceList() with a type of 96.

From there you can import from default content then use Name2Index to get the index and use the index in the existing Line Style functions to use the Line Type.

Link to comment

There seems to be no logical structure in these Line Patterns,

the desired pattern is located in the VW-Library under index (57);

Once imorted it gets - following the Name2Index-command - index (9);

To apply it in a drawing I need index (-5)

Is there any possibility to use the name 'Type 06' for all of these indexes?

PROCEDURE Draw_Line_Pattern;
VAR
 Id, Num	: LONGINT;
 Obj_H 	: HANDLE;
 Patr 	: INTEGER;
BEGIN
 PushAttrs;

 Id 	:= BuildResourceList (96, -14, 'Resources - Line Patterns', Num);
 Obj_H	:= ImportResourceToCurrentFile (Id, 57);

 Patr	:= Name2Index ('[LP] Type 06');
 Message (Patr);

 PenPat (-5);
 MoveTo (-500, 0);
 LineTo (500, 0);

 PopAttrs;
END;
RUN (Draw_Line_Pattern);

Edited by DeSignature
Link to comment
  • Vectorworks, Inc Employee

The indexes are file bases other than -1 through -10 which are there for legacy support and should produce a constant line style.

The index in the file depends on what other line types are in the current document and if other line types are added to the defaults the index in the list may change.

You need to search the list by name then import if necessary.

Id := BuildResourceList (96, 174, '', Num);

For I := 1 to Num do

Begin

If GetNameFromResourceList(ID,I) = '[LP] Type 06' then

Obj_H := ImportResourceToCurrentFile (Id, I);

End;

Also since you have the handle use GetLSN() to get the Line Type Index rather than using Name2Index.

The other option if you want to force a certain simple line type is to create one using SetDashStyleN()

Warning: SetDashStyleN will change the active document's default Line Type.

Link to comment

My original goal was to merely expand a Custom Tool script. I have a script that calls the Line Tool and sets the Class. The corresponding Class is preset with the desired attributes but is also set to draw with a custom Line Type.

My tools work well as long as they are used in a file that contains the proper classes and line types that are in the script and the classes are set to use the desired Line Type. I wanted to expand the scripts so that if I ran these Custom Tools in a file without those Class settings or Line Types the script would set them accordingly. Thus the need to import a Line Type from the Default content and set a Class to use that Line Type.

I'm a pretty Novice script writer and the information you have provided helps.

For the time being, however, I have all of my CAD users simply opening up a template file that contains all of our new custom line objects set to the proper class and line type. One cut and paste of the whole group imports all the Classes and their settings and also imports all the Line Types. Doing this makes all the Tool scripts work as desired.

Improving the scripts, however, will eliminate this step.

Link to comment
  • 3 months later...

I still fail at assigning a Linetype to an object trough script knowing the name of that linetype.

None of the below functions result in selecting the correct linetype.. Anyone ?

Id := BuildResourceList (96, 0, '', Num);
For Counter := 1 to Num do Begin
If GetNameFromResourceList(ID,Counter) = '[LP] Cirkels' THEN	BEGIN
	ResourceHd := ImportResourceToCurrentFile (Id, Counter);
	ResourceHd := GetResourceFromList (Id, Counter);

	{SetLS(h,-Name2Index('[LP] Cirkels'));}
	{SetLS(h,-GetLs(ResourceHd));}
	{SetLS(h,-Counter);}
END;
End;

Link to comment
  • Vectorworks, Inc Employee

So close...

You need to use the new call for line styles SetLSN NOT SetLS.

Id := BuildResourceList (96, 0, '', Num);
For Counter := 1 to Num do 
       Begin
If GetNameFromResourceList(ID,Counter) = '[LP] Cirkels' THEN	
               BEGIN
	ResourceHd := ImportResourceToCurrentFile (Id, Counter);
	SetLSN(h,-Name2Index('[LP] Cirkels'));
        END;
       End;

Link to comment
  • Vectorworks, Inc Employee

FYI: I found something while testing your problem. Accessing the default folder "Attributes - Line Types" using the constant 153 is currently not working for the English version. It will be fixed in a future version. For now you can use BuildResourceList(14,"Attributes - Line Types").

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