Jump to content

PASTE IN PLACE OBJECT(S) ON SELECTED LAYERS


rebu1985

Recommended Posts

Hi guys,

 

I have found in the forum a topic which i would like to know because it would be really useful for me. You can find below:

 

Copy object(s) to Paste (this step is performed pre vs execution)

Execute vs

1. VS Brings up a dialog window with available design and sheet layers

2. User selects layer(s) on to which the object(s) to be pasted in place

3. Click "OK"

4. Layer visibility set to "Active Only", the script activates each selected layer

in turn and pastes in place initially copied object(s)

 

The purpose of this script its to have some objects (stairs, lifts, structure,etc) of a building keep in the same position in different design layers (they work as floor levels).

 

Laura

  • Like 1
Link to comment

Bounded stairs can be displayed automatically in both the lower and upper Layer in 2d.

In 3d the Layer the stair will be visible whenever its layer is visible.

This functionality could/ought to be expanded to include elevators, arguably one Elevator object that is visible on all selected Story layers.

Link to comment

Writing the dialog code will be the harder part of this task. To paste on multiple layers just requires a simple loop where the layer name can be accessed each time, and you won't need to copy before running the script, the script can do it for you. Just select your objects and run your script.

 

The code will look something like this:

BEGIN
<< Dialog code to select multiple layers and save in an array >>

if not DidCancel then begin
	DoMenuTextByName('Copy', 0);		{ copy selected objects to paste }
	for I := 1 to NumSelectedLayers do begin
		Layer(LayerNameArray[I]);	{ change  active layer for pasting }
		DoMenuTextByName('Paste In Place', 0);
	end;		{ for }
end;		{ if }
END;

 

Link to comment

Hi guys,

 

I have been working on the script and i have done this one. The script is still wrong and I dont know the answer.

Could you help me guys, please?

 

PROCEDURE CreateDialog;
VAR
h: HANDLE;
nl,i,a: INTEGER;
layer : STRING;
dupl,go,ok : BOOLEAN;
Layers: DYNARRAY OF STRING;

FUNCTION 
result : INTEGER;
VAR id : INTEGER;
BEGIN
id := CreateLayout('Revise Layer Link',TRUE,'ok', 'Cancel');

CreateStaticText(id,4,'Layers:',-1);
CreatePulldownMenu(id,5,32);

CreateCheckBox(dialogID,30,'Follow objects');

CreateCheckBox(id,40,'duplicate objects');
CreateGroupBox(id,6,'Layers Options',TRUE);
CreateCheckBox(id,7,'Planta Sótano');
CreateCheckBox(id,8,'Planta Baja');
CreateCheckBox(id,9,'Planta 1');
CreateCheckBox(id,10,'Planta 2');
CreateCheckBox(id,11,'Planta 3');
CreateCheckBox(id,12,'Planta 4');
CreateCheckBox(id,13,'Planta 5');
CreateCheckBox(id,14,'Planta 6');
CreateCheckBox(id,15,'Planta 7');
CreateCheckBox(id,16,'Planta 8');
CreateCheckBox(id,17,'Planta Atico');
CreateCheckBox(id,18,'Planta Cubierta');

SetFirstLayoutItem(id, 4);
SetBelowItem (id,4,6,0,0);
SetFirstGroupItem(id,6,7);
SetBelowItem (id,7,8,0,0);
SetBelowItem (id,8,9,0,0);
SetBelowItem (id,9,10,0,0);
SetBelowItem (id,10,11,0,0);
SetBelowItem (id,11,12,0,0);
SetBelowItem (id,12,13,0,0);
SetBelowItem (id,13,14,0,0);
SetBelowItem (id,14,15,0,0);
SetBelowItem (id,15,16,0,0);
SetBelowItem (id,16,17,0,0);
SetBelowItem (id,17,18,0,0);

SetBelowItem(id,18,30,0,0);

SetBelowItem(id,30,40,0,0);

SetHelpString(a,'Select a layer to transfer your selected object');

SetHelpString(30,'Go to the selected option with the actual visibility settings');

SetHelpString(40,'Select to duplicate your selected object');


result := RunLayoutDialog(id,NIL)
END;

Procedure GetLayers;

BEGIN

nl:= NumLayers;

ALLOCATE Layers[1..nl];

h:=FLayer;

For i:=1 TO nl DO BEGIN

Layers:=GetLNAME(h);
END;

END;

 

Procedure Drive_LayerClass;
VAR 
item: LONGINT; 
data: LONGINT;
BEGIN
CASE item OF SetupDialogC
BEGIN GetLayers; IF Layers=layer THEN SELChoice(a,i,ok);
END; OK:=TRUE; END;
BEGIN GetSelChoice(a,0,i,Layers);

go:=ItemSel(30);

dupl:=ItemSel(40);
END;
END;
END;
END;

RUN(CreateDialog);

Edited by rebu1985
Link to comment

hi guys,

 

I have created my dialog code for copying objects to selected layers.

All info which i have found its about copying objects to all layers but i would like to know how to do it if I just wanna duplicate to selected ones. I dont know how the script should be to transfer the info from the dialog to the object.

 

PROCEDURE CreateDialog;

VAR result : INTEGER;

id : INTEGER;

BEGIN

id := CreateLayout('Revise Layer Link',TRUE,'ok', 'Cancel');

CreateStaticText(id,4,'Layers:',-1);

CreatePulldownMenu(id,5,32);

CreateGroupBox(id,6,'Layers Options',TRUE);

CreateCheckBox(id,7,'Planta Sótano');

CreateCheckBox(id,8,'Planta Baja');

CreateCheckBox(id,9,'Planta 1');

CreateCheckBox(id,10,'Planta 2');

CreateCheckBox(id,11,'Planta 3');

CreateCheckBox(id,12,'Planta 4');

CreateCheckBox(id,13,'Planta 5');

CreateCheckBox(id,14,'Planta 6');

CreateCheckBox(id,15,'Planta 7');

CreateCheckBox(id,16,'Planta 8');

CreateCheckBox(id,17,'Planta Atico');

CreateCheckBox(id,18,'Planta Cubierta');

SetFirstLayoutItem(id, 4);

SetBelowItem (id,4,6,0,0);

SetFirstGroupItem(id,6,7);

SetBelowItem (id,7,8,0,0);

SetBelowItem (id,8,9,0,0);

SetBelowItem (id,9,10,0,0);

SetBelowItem (id,10,11,0,0);

SetBelowItem (id,11,12,0,0);

SetBelowItem (id,12,13,0,0);

SetBelowItem (id,13,14,0,0);

SetBelowItem (id,14,15,0,0);

SetBelowItem (id,15,16,0,0);

SetBelowItem (id,16,17,0,0);

SetBelowItem (id,17,18,0,0);

SetBelowItem(id,18,30,0,0);

SetBelowItem(id,30,40,0,0);

result := RunLayoutDialog(id,NIL) END;
RUN (CreateDialog);

 

Link to comment

Laura,

   You are going to need to use:

CreateListBoxN(dialogID, itemID, widthInCharacters, heightInCharacters, isMultipleSelect);

to display your layer names. The last parameter should be TRUE to allow multiple selections.

 

   Also, you need to call a procedure to handle your dialog events, i.e., what to do when you click controls:

result := RunLayoutDialog(id, DialogHandler);

 

   DialogHandler has two parameters:

procedure DialogHandler ( var item :Longint; data Longint );

and usually contains a CASE statement to handle the events:

case item of

...

end;  { case }


   The first item in the CASE is usually:

SetupDialogC: begin

  { setup code goes here ( load your list with layer names ) }

  { use AddChoice(dialogid, dialogitem#, list_text, list#); }

end;

The other CASE items will be your dialog control item numbers if needed.


   For item 1 (OK) in the CASE statement, you can harvest the selected items in your list there. That is, fill a global array variable with your Layer Names based on the selected list items. After your dialog code exits  you will use the array to perform your PASTE operation.

 

Raymond

Edited by MullinRJ
Link to comment

Laura,

 

You'll also need:

GetSelectedChoiceInfo(dialogID, componentID :LONGINT; startIndex :INTEGER;
                                            VAR SelectedIndex :INTEGER; VAR SelectedChoiceText :STRING);

to determine which items are selected.

 

Raymond

Edited by MullinRJ
Link to comment

Hi MullinRJ,

 

I have been working on your comments to do my script and i have done this. I still have some mistakes and i guess its about the array function.

Could you help me, please?

 

 

PROCEDURE dialogl_Main;
    VAR
    dialog1 : INTEGER;

    PROCEDURE dialog1_Setup;
    BEGIN
        dialog1 := CreateLayout( 'CreateListBox', FALSE, 'OK', 'Cancel' );
        CreateListBoxN( dialog1, 4, 30, 10, TRUE );
        SetFirstLayoutItem( dialog1, 4 );
    END;

    PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT);
    VAR
    i        : INTEGER;
    nl        : INTEGER;
    layers    : DYNARRAY OF STRING;
    h        : HANDLE;
    
    BEGIN
        CASE item OF
            SetupDialogC:
            BEGIN
                
                AddChoice( dialog1, 4, 'PLANTA 1', 0 );
                AddChoice( dialog1, 4, 'PLANTA 2', 0 );
                AddChoice( dialog1, 4, 'PLANTA 3', 0 );
                
            END;
        1:    BEGIN
            GetSelectedChoiceInfo(dialog1, 4, 1, i, layers);
            END;
        4:    BEGIN
            nl:=NumLayers;
            Layers:=GetLNAME (h);
            DoMenuTextByName('Copy', 0);
            FOR i:=1 TO nl DO BEGIN
            DoMenuTextByName('Paste In Place', 0);
        END;
    END;

BEGIN
    dialog1_Setup;
    IF RunLayoutDialog(dialog1, Dialog_Handler) = 1 THEN BEGIN
END;

RUN(dialogl_Main);

Link to comment

I did something like this a few years ago, and I think it was working then. Now the setting of check boxed is not working properly. I was going to find time to fix it and post it, but I know I am not getting to it this week, so here it is in it's broken state. I hope this helps.

 

Use with caution. It appears to continually create duplicate objects and will basically crash VW or bring it to a halt as it sits now. The last time I ran it, I got 21,000,000 million duplicates. ;-)

 

PROCEDURE LB_LayerList;

{©2008 Pat Stanford, pat@coviana.com}
{Licenses under the LGPL. No Rights Reserved}
{Use at your own risk. Code is broken as written}
{No warranty or suitability for use expressed or implied}

VAR
B1:boolean;
dialog1 : LongInt;
kImageCheck,kImageBlank,kImageSheet,kImageView : Integer;
LayerArray : DYNARRAY[] of String;
NumLayers, N1, CheckedLayers : Integer;

FirstObjectToCopy : Handle;
ThisObjectToCopy : Handle;

LayerToCopyFrom : Handle;
LayerNameToCopyFrom : String;
ThisLayer : String;
ThisDuplicate : Handle;

{-----------------------------------------------------------------------------}
	FUNCTION GetPlugInString(ndx :INTEGER) :STRING;
		BEGIN
			CASE ndx OF
				{Static Text}
				3001: GetPlugInString := 'OK';
				3002: GetPlugInString := 'Cancel';
				3003: GetPlugInString := 'Layers';
			END;
		END;
{----------------------------------------------------------------------------} 
	PROCEDURE Dialog_Setup;
		VAR
			cnt : INTEGER;
			BSB : Boolean;
		BEGIN
			dialog1 := CreateResizableLayout(GetPlugInString(3003),TRUE,GetPlugInString(3001),GetPlugInString(3002),TRUE,TRUE);
			CreateLB(dialog1,4,34,15);
					
			
			CreatePushButton(dialog1,5,'All');
			CreatePushButton(dialog1,6,'None');

			SetFirstLayoutItem(dialog1, 4);
			SetBelowItem(dialog1,4,5,0,0);
			SetBelowItem(dialog1,4,6,0,0);
			SetRightItem(dialog1,5,6,0,0);

			SetEdgeBinding(dialog1,5,False,False,False,True);
			SetEdgeBinding(dialog1,6,False,False,False,True);

		END;

{-----------------------------------------------------------------------------}

	PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT);
		Var
			ColNum,TempI,I : Integer;
			SheetTypeIcon : Integer;
			BSB : Boolean;
			BSS : String;
			LayerHand : Handle;
			LayerName,SelectedIconString : String;
			SheetIconNumber,SelectedIconNumber : Integer;
			
		BEGIN
			CASE item OF
				SetupDialogC: 
					BEGIN
					{These need to be declared as globals otherwise they won't work outside of setup.}
					kImageCheck := AddLBImage(dialog1,4,1,11022);
					kImageBlank := AddLBImage(dialog1,4,1,11023);
					kImageSheet := AddLBImage(dialog1,4,1,11024);
					kImageView := AddLBImage(dialog1,4,1,11025);
					
					ColNum := InsertLBColumn(dialog1,4,0,'Copy To',50);
					BSB := SetLBControlType(dialog1,4,ColNum,3);
					BSB := SetLBItemDisplayType(dialog1,4,ColNum,1);
					BSB := SetLBColumnWidth(dialog1,4,0,0,20);

					{ColNum := InsertLBColumn(dialog1,4,0,'',50);}{This crashes VW}
					
					ColNum := InsertLBColumn(dialog1,4,1,'Layer Name',100);
					BSB := SetLBControlType(dialog1,4,ColNum,1);
					BSB := SetLBItemDisplayType(dialog1,4,ColNum,3);
					BSB := SetLBColumnWidth(dialog1,4,1,1,200);
				
					ColNum := InsertLBColumnDataItem(dialog1,4,0,'Checked',kImageCheck,-1,0);
					ColNum := InsertLBColumnDataItem(dialog1,4,0,'UnChecked',kImageBlank,-1,0);
					
					{Traversing from LLayer by PrevObj doesn't work with Sheet Layers}
					LayerHand := FLayer;
					I := 0;
					
					While LayerHand <> NiL do
						Begin
							If GetObjectVariableInt(LayerHand,154) = 2 then
								SheetTypeIcon := kImageSheet
							else	SheetTypeIcon := kImageView;
							
							ColNum := InsertLBColumnDataItem(dialog1,4,1,GetLName(LayerHand),SheetTypeIcon,SheetTypeIcon,0);
							TempI := InsertLBItem (dialog1, 4, I, GetLName(LayerHand));
							BSB := SetLBItemUsingColumnDataItem (dialog1, 4, I, 1, ColNum);
							BSB := SetLBItemUsingColumnDataItem (dialog1, 4, I, 0, 1);
							I := I+1;
							LayerHand := NextObj(LayerHand);
						End;
					
					
					EnableLBColumnLines(dialog1,4,True);
					END;
				1:	BEGIN
						NumLayers:=GetNumLBItems(dialog1,4);
						CheckedLayers:=0;
						Allocate LayerArray[1..NumLayers];
						For I := 1 to NumLayers do 
							Begin
								BSB := GetLBItemInfo(dialog1,4,I-1,1,LayerName,SheetIconNumber);
								BSB := GetLBItemInfo(dialog1,4,I-1,0,SelectedIconString,SelectedIconNumber);
								If SelectedIconString = 'Checked' then
									Begin
										CheckedLayers := CheckedLayers+1;
										If SheetIconNumber = kImageSheet then
										LayerArray[CheckedLayers]:=LayerName;
				
										If SheetIconNumber = kImageView then 
											LayerArray[CheckedLayers]:=LayerName;
									End;		{If}
							End;		{For}
					End;		{1}

				5:	Begin       
						For i:=0 to GetNumLBItems(dialog1, 4)Do 
							Begin
								BSB:=SetLBItemInfo(dialog1,4,i,0,'Checked',kImageCheck);
							End;		{For}
					End;		{5}

				6:	Begin
						For I := 0 to GetNumLBItems(dialog1,4) do
							Begin
								BSB:=SetLBItemInfo(dialog1,4,i,0,'Unchecked',kImageBlank);
							end;		{For}
					end;		{6}

			END; {Case}
			BSB:=RefreshLB(dialog1,4);
		END; {Procedure}
{-----------------------------------------------------------------------------}

	function ResourceIsOK :BOOLEAN;
		BEGIN
			IF SetVSResourceFile('IP Resources') 
				THEN ResourceIsOK := TRUE
			ELSE Message('The "IP Resources" file was not found.');
		END;
{-----------------------------------------------------------------------------}

BEGIN {Main}
	FirstObjectToCopy := FSActLayer;
	LayerToCopyFrom := ActLayer;
	LayerNameToCopyFrom := GetLName(LayerToCopyFrom);



	IF ResourceIsOK THEN Dialog_Setup;
	IF RunLayoutDialog(dialog1,Dialog_Handler) = 1 THEN 
		BEGIN
			SysBeep;
			For N1 := 1 to CheckedLayers do
				Begin
					ThisLayer:=LayerArray[N1];
					If ThisLayer <> LayerNameToCopyFrom Then
						Begin
							ThisObjectToCopy := FirstObjectToCopy;
							While ThisObjectToCopy <> Nil do
								Begin
									ThisDuplicate := CreateDuplicateObject(ThisObjectToCopy,GetLayerByName(ThisLayer));
									ThisObjectToCopy := NextSObj(ThisObjectToCopy);
								End;
						End; {If}
				End; {For}
		END; {If}
	Wait(1);
	ClrMessage;

END;

Run(LB_LayerList);

 

Link to comment

Laura,

   I haven't looked at Pat's code, but he is using a ListBrowser approach. It isn't wrong, but it's a lot more complicated than what you need (IMO). I added comments to your code and commented out pieces that were causing errors. It runs but doesn't do much. I hope this helps.

 

Raymond

PROCEDURE dialogl_Main;
VAR
    dialog1 : INTEGER;
    
    PROCEDURE dialog1_Setup;
    BEGIN
        dialog1 := CreateLayout( 'CreateListBox', FALSE, 'OK', 'Cancel' );
        CreateListBoxN( dialog1, 4, 30, 10, TRUE );
        SetFirstLayoutItem( dialog1, 4 );
    END;        { dialog1_Setup }


    PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT);
    VAR
        i         : INTEGER;
        nl        : INTEGER;
        layers    : DYNARRAY OF STRING;        { this needs to be GLOBAL or it will be rewritten on each dialog event. }
        h         : HANDLE;
    
    BEGIN
        CASE item OF
            SetupDialogC:
            BEGIN
                { you need a loop here to add your design layer names to the dialog ListBox using AddChoice() }

                { are these layer names? they are being added to the Layer Name ListBox. }
                { or is this test data? (which is OK) } 
                AddChoice( dialog1, 4, 'PLANTA 1', 0 );
                AddChoice( dialog1, 4, 'PLANTA 2', 0 );
                AddChoice( dialog1, 4, 'PLANTA 3', 0 );
            END;        { SetupDialogC }
    
            1: BEGIN
                { this only gets one choice starting at the second line (line 1) }
                { the lines start at "line 0". Not the documentation says this function is "0-based". }
                { there is no consistency in VS as to what is "0-based" or "1-based". You have to read. }
                { put this in a loop to get all choices and save the text in your array as you go. }

{                GetSelectedChoiceInfo(dialog1, 4, 1, i, layers);        }
                
                { count your design layers and allocate your Layer Name array here. }
                { then add your choices to it with a loop. }
                { GetSelectedChoiceInfo() will return -1 when it can't find any more selections }
            END;        { 1 }

            4: BEGIN
                { this code is in the wrong place }
                { pasting needs to be done in ITEM 1 (at the end) or in the main program after the dialog is done. }
                { copying needs to be done on SetupDialogC event, or before the dialog code starts. }
                { item 4 doesn't really need any control. Selection is handled by the ModernDialog machine. }
(*
                nl := NumLayers;
                Layers := GetLNAME (h);
                DoMenuTextByName('Copy', 0);
                FOR i :=1 TO nl DO BEGIN
                DoMenuTextByName('Paste In Place', 0);
*)
            END;        { 4 }
        END;        { case }
    END;        { Dialog_Handler }        { this was missing }
    
    
BEGIN
    dialog1_Setup;
    IF (RunLayoutDialog(dialog1, Dialog_Handler) = 1) THEN BEGIN
    END;        { this was missing }
END;
RUN(dialogl_Main);

 

Link to comment
  • 5 years later...
  • 1 month later...

Hi guys,

I write you because in a newer version of vectorworks I cant run the scrip properly and I dont know why.

I have used Pat´s scrip in VW2015 but in version 2020 I have the problems of selecting the layers, the only option I can do is selecting all/none. Can you help me, guys?

 

PROCEDURE LB_LayerList;

VAR
B1:boolean;
dialog1 : LongInt;
kImageCheck,kImageBlank,kImageSheet,kImageView : Integer;
LayerArray : DYNARRAY[] of String;
NumLayers, N1, CheckedLayers : Integer;

FirstObjectToCopy : Handle;
ThisObjectToCopy : Handle;

LayerToCopyFrom : Handle;
LayerNameToCopyFrom : String;
ThisLayer : String;
ThisDuplicate : Handle;

{-----------------------------------------------------------------------------}
FUNCTION GetPlugInString(ndx :INTEGER) :STRING;
        BEGIN
            CASE ndx OF
                {Static Text}
                3001: GetPlugInString := 'OK';
                3002: GetPlugInString := 'Cancel';
                3003: GetPlugInString := 'Layers';
            END;
        END;
{----------------------------------------------------------------------------} 
    PROCEDURE Dialog_Setup;
        VAR
            cnt : INTEGER;
            BSB : Boolean;
        BEGIN
            dialog1 := CreateResizableLayout (GetPlugInString(3003),TRUE,GetPlugInString(3001),GetPlugInString(3002),TRUE,TRUE);
            CreateLB(dialog1,4,34,15);
                    
            
            CreatePushButton(dialog1,5,'All');
            CreatePushButton(dialog1,6,'None');

            SetFirstLayoutItem(dialog1, 4);
            SetBelowItem(dialog1,4,5,0,0);
            SetBelowItem(dialog1,4,6,0,0);
            SetRightItem(dialog1,5,6,0,0);

            SetEdgeBinding(dialog1,5,False,False,False,True);
            SetEdgeBinding(dialog1,6,False,False,False,True);

        END;

{-----------------------------------------------------------------------------}

    PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT);
        Var
            ColNum,TempI,I : Integer;
            SheetTypeIcon : Integer;
            BSB : Boolean;
            BSS : String;
            LayerHand : Handle;
            LayerName,SelectedIconString : String;
            SheetIconNumber,SelectedIconNumber : Integer;
            
        BEGIN
            CASE item OF
                SetupDialogC: 
                    BEGIN
                    {These need to be declared as globals otherwise they won't work outside of setup.}
                    kImageCheck := AddLBImage(dialog1,4,1,11022);
                    kImageBlank := AddLBImage(dialog1,4,1,11023);
                    kImageSheet := AddLBImage(dialog1,4,1,11024);
                    kImageView := AddLBImage(dialog1,4,1,11025);
                    
                    ColNum := InsertLBColumn(dialog1,4,0,'Copy To',50);
                    BSB := SetLBControlType(dialog1,4,ColNum,3);
                    BSB := SetLBItemDisplayType(dialog1,4,ColNum,1);
                    BSB := SetLBColumnWidth(dialog1,4,0,0,20);

                    {ColNum := InsertLBColumn(dialog1,4,0,'',50);}{This crashes VW}
                    
                    ColNum := InsertLBColumn(dialog1,4,1,'Layer Name',100);
                    BSB := SetLBControlType(dialog1,4,ColNum,1);
                    BSB := SetLBItemDisplayType(dialog1,4,ColNum,3);
                    BSB := SetLBColumnWidth(dialog1,4,1,1,200);
                
                    ColNum := InsertLBColumnDataItem(dialog1,4,0,'Checked',kImageCheck,-1,0);
                    ColNum := InsertLBColumnDataItem(dialog1,4,0,'UnChecked',kImageBlank,-1,0);
                    
                    {Traversing from LLayer by PrevObj doesn't work with Sheet Layers}
                    LayerHand := FLayer;
                    I := 0;
                    
                    While LayerHand <> NiL do
                        Begin
                            If GetObjectVariableInt(LayerHand,154) = 2 then
                                SheetTypeIcon := kImageSheet
                            else    SheetTypeIcon := kImageView;
                            
                            ColNum := InsertLBColumnDataItem(dialog1,4,1,GetLName(LayerHand),SheetTypeIcon,SheetTypeIcon,0);
                            TempI := InsertLBItem (dialog1, 4, I, GetLName(LayerHand));
                            BSB := SetLBItemUsingColumnDataItem (dialog1, 4, I, 1, ColNum);
                            BSB := SetLBItemUsingColumnDataItem (dialog1, 4, I, 0, 1);
                            I := I+1;
                            LayerHand := NextObj(LayerHand);
                        End;
                    
                    
                    EnableLBColumnLines(dialog1,4,True);
                    END;
                1:    BEGIN
                        NumLayers:=GetNumLBItems(dialog1,4);
                        CheckedLayers:=0;
                        Allocate LayerArray[1..NumLayers];
                        For I := 1 to NumLayers do 
                            Begin
                                BSB := GetLBItemInfo(dialog1,4,I-1,1,LayerName,SheetIconNumber);
                                BSB := GetLBItemInfo(dialog1,4,I-1,0,SelectedIconString,SelectedIconNumber);
                                If SelectedIconString = 'Checked' then
                                    Begin
                                        CheckedLayers := CheckedLayers+1;
                                        If SheetIconNumber = kImageSheet then
                                        LayerArray[CheckedLayers]:=LayerName;
                
                                        If SheetIconNumber = kImageView then 
                                            LayerArray[CheckedLayers]:=LayerName;
                                    End;        {If}
                            End;        {For}
                    End;        {1}

                5:    Begin       
                        For i:=0 to GetNumLBItems(dialog1, 4)Do 
                            Begin
                                BSB:=SetLBItemInfo(dialog1,4,i,0,'Checked',kImageCheck);
                            End;        {For}
                    End;        {5}

                6:    Begin
                        For I := 0 to GetNumLBItems(dialog1,4) do
                            Begin
                                BSB:=SetLBItemInfo(dialog1,4,i,0,'Unchecked',kImageBlank);
                            end;        {For}
                    end;        {6}

            END; {Case}
            BSB:=RefreshLB(dialog1,4);
        END; {Procedure}
{-----------------------------------------------------------------------------}

    function ResourceIsOK :BOOLEAN;
        BEGIN
            IF SetVSResourceFile('IP Resources') 
                THEN ResourceIsOK := TRUE
            ELSE Message('The "IP Resources" file was not found.');
        END;
{-----------------------------------------------------------------------------}

BEGIN {Main}
    FirstObjectToCopy := FSActLayer;
    LayerToCopyFrom := ActLayer;
    LayerNameToCopyFrom := GetLName(LayerToCopyFrom);

    IF ResourceIsOK THEN Dialog_Setup;
    IF RunLayoutDialog(dialog1,Dialog_Handler) = 1 THEN 
        BEGIN
            SysBeep;
            For N1 := 1 to CheckedLayers do
                Begin
                    ThisLayer:=LayerArray[N1];
                    If ThisLayer <> LayerNameToCopyFrom Then
                        Begin
                            ThisObjectToCopy := FirstObjectToCopy;
                            While ThisObjectToCopy <> Nil do
                                Begin
                                    ThisDuplicate := CreateDuplicateObject(ThisObjectToCopy,GetLayerByName(ThisLayer));
                                    ThisObjectToCopy := NextSObj(ThisObjectToCopy);
                                End;
                        End; {If}
                End; {For}
        END; {If}
    Wait(1);
    ClrMessage;

END;

Run(LB_LayerList);
 

Link to comment

@rebu1985 The reason the script no longer works is because the AddLBImage function was made obsolete in 2012.  The new function is AddListBrowserImage which takes in a file path for the icon image rather than using an internal index.  The advantage is that it allows you to use custom icons.  The disadvantage is you now have to know the file path for the standard icon images, which does not appear in any appendix or function reference that I know of (but I would be very interested to see).  You can get the script working by replacing lines 68-71 with:

kImageCheck := AddListBrowserImage(dialog1,4,'Vectorworks/Standard Images/Checkmark.png');
kImageBlank := AddListBrowserImage(dialog1,4,'Vectorworks/Standard Images/Blank.png');
kImageSheet := AddListBrowserImage(dialog1,4,'Vectorworks/Standard Images/[Sheet Layer Icon Name]');
kImageView := AddListBrowserImage(dialog1,4,'Vectorworks/Standard Images/[Design Layer Icon Name]');

 

Unfortunately, I do not know the icon names for Design Layers or Sheet Layers, so you'll have to figure that out (unless someone here knows offhand).  For now, you can comment out those lines and the rest of the script will run just fine.  If someone has a Mac, the process for extracting icons is listed here under the heading Use icons from Vectorworks.app.  Placing the name where I have the bracketed text will cause the correct icon to be loaded in with the layer name.

  • Like 1
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...