Jump to content
Developer Wiki and Function Reference Links Read more... ×
Sign in to follow this  
myf

change hatch fill via script

Recommended Posts

Hi,

I want to select object with specific hatch fill

and change the fill of the selected objects then.

If possible with all objects in drawing

(including groups and symbols)

How can I reach this via vectorscript?

thanks

Share this post


Link to post

Here is a peace of code,

I can select the objects with the specified hatch,

but i don't now how to set the hatch then (see Set????)

and if it works, how to select the hatch in an interactive way...

PROCEDURE CHHatch;

PROCEDURE EditHatch( ObjHand : HANDLE );
BEGIN

Set?????(ObjHand, ??? 'Hatchname'); 
ResetObject( ObjHand );
END;

BEGIN
ForEachObject( EditHatch, HFI='Hatchname' );
ReDrawAll;
END;

RUN(CHHatch);

thanks for help

Share this post


Link to post

Thank You!

I have to try out.

How do you come from Foreachobj

to SetVectorfill,

it doesn't work like my first example.

Just works with SetLW...

I always get a "Function"-ERROR,

how to use this Functions instead of Procedures

Edited by myf

Share this post


Link to post

A wild guess, but maybe you forgot to assign the boolean to the function?

This example will replace the hatch "Old Hatch" (on every object that has that hatch) with "New Hatch".

PROCEDURE CHHatch;

PROCEDURE EditHatch( ObjHand : HANDLE );
VAR
	bool : BOOLEAN;
BEGIN
	bool:=SetVectorFill (ObjHand, 'New Hatch');
	ResetObject( ObjHand );
END;

BEGIN
ForEachObject( EditHatch, HFI='Old Hatch' );
END;
RUN(CHHatch);

Share this post


Link to post

Wow,

I don't know why it works,

but it works fine

Dank je wel!

Share this post


Link to post

I found this example-code at

http://www.nemetschek.net/support/custom/vscript/example.php

to choose an Hatch,

but I have no idea to get it combined the my ChHatch-Script above and get two times this window to choose the old Hatch and then the new one.

Can someone explain me how to combine (these) scripts and get the VARs from one to another?


PROCEDURE ImagePopTest;
VAR
gHatchList:dynarray[] of STRING;

gHatchCount,gDlogID,gDlogResult : INTEGER;
gHatchChoice : STRING;

gOKdlog : BOOLEAN;


FUNCTION BuildHatchList:INTEGER;

VAR temp_i,temp_cnt:INTEGER;


BEGIN
temp_cnt := 0;

FOR temp_i := 1 TO NameNum DO IF (getobject(namelist(temp_i)) <> NIL) & (gettype(getobject(namelist(temp_i))) = 66) THEN BEGIN
	temp_cnt := temp_cnt +1;

	allocate gHatchList[1..temp_cnt];

	gHatchList[temp_cnt] := namelist(temp_i);

	END;

BuildHatchList := temp_cnt;

END;

FUNCTION Define_Dialog: INTEGER;

VAR dialogID,i : INTEGER;


BEGIN
dialogID := CreateLayout('Hatch Picker Dialog',True,'OK','Cancel');	CreateStaticText(dialogID,4,'Select the Hatch:',-1);
CreateControl(dialogID,5,10,'',0);


SetFirstLayoutItem(dialogID,4);
SetBelowItem(dialogID,4,5,0,0);

Define_Dialog := dialogID;

END;

PROCEDURE Drive_Dialog(VAR item:LONGINT; data:LONGINT);

VAR temp_i,i:INTEGER; temp_s:STRING; result:BOOLEAN;


BEGIN
CASE item OF
	SetupDialogC: FOR i := 1 TO gHatchCount DO temp_i := InsertImagePopupObjectItem(gDlogID,5,gHatchList[i]);		1:gHatchChoice := GetImagePopupObject(gDlogID,5,getImagePopupSelectedItem(gDlogID,5));

	END;
{of CASE}
END;


BEGIN {MAIN}
gHatchCount := BuildHatchList;

gDlogID := Define_Dialog;

gOKdlog := VerifyLayout(gDlogID);

IF gOKdlog THEN gDlogResult := RunLayoutDialog(gDlogID,Drive_Dialog);
IF (gDlogResult = 2) THEN alrtdialog('You canceled') ELSE alrtdialog(concat('You chose ',gHatchChoice));

END;Run(ImagePopTest);

Thank You!

Share this post


Link to post

This one would work.

I don't have the time now to explain the variable part though, sorry :S...

But ask along and i'm sure somebody would explain it how it works.

PROCEDURE ImagePopTest;
VAR
gHatchList:dynarray[] of STRING;
gHatchCount,gDlogID,gDlogResult : INTEGER;
gHatchChoiceOld,gHatchChoiceNew,gCrit : STRING;
gOKdlog : BOOLEAN;

{Subfunction BuildHatchList}
FUNCTION BuildHatchList:INTEGER;
VAR
	temp_i,temp_cnt:INTEGER;
BEGIN
	temp_cnt := 0;
	FOR temp_i := 1 TO NameNum DO IF (getobject(namelist(temp_i)) <> NIL) & (gettype(getobject(namelist(temp_i))) = 66) THEN
	BEGIN
		temp_cnt := temp_cnt +1;
		allocate gHatchList[1..temp_cnt];
		gHatchList[temp_cnt] := namelist(temp_i);
	END;
	BuildHatchList := temp_cnt;
END;
{End Sub}

{Subfunction Define_Dialog}
FUNCTION Define_Dialog: INTEGER;
VAR
	dialogID,i : INTEGER;
BEGIN
	dialogID := CreateLayout('Hatch Picker Dialog',True,'OK','Cancel');
	CreateStaticText(dialogID,4,'Select the old Hatch:',-1);
	CreateControl(dialogID,5,10,'',0);
	CreateStaticText(dialogID,6,'Select the new Hatch:',-1);
	CreateControl(dialogID,7,10,'',0);
	SetFirstLayoutItem(dialogID,4);
	SetBelowItem(dialogID,4,5,0,0);
	SetBelowItem(dialogID,5,6,0,0);
	SetBelowItem(dialogID,6,7,0,0);
	Define_Dialog := dialogID;
END;
{End Sub}

{Subprocedure Drive_Dialog}
PROCEDURE Drive_Dialog(VAR item:LONGINT; data:LONGINT);
VAR
	temp_i,i:INTEGER;
	temp_s:STRING;
	result:BOOLEAN;
BEGIN
	CASE item OF
		SetupDialogC:
		BEGIN
			FOR i := 1 TO gHatchCount DO temp_i := InsertImagePopupObjectItem(gDlogID,5,gHatchList[i]);
			FOR i := 1 TO gHatchCount DO temp_i := InsertImagePopupObjectItem(gDlogID,7,gHatchList[i]);
		END;
		1:
		BEGIN
			gHatchChoiceOld := GetImagePopupObject(gDlogID,5,getImagePopupSelectedItem(gDlogID,5));
			gHatchChoiceNew := GetImagePopupObject(gDlogID,7,getImagePopupSelectedItem(gDlogID,7));
		END;
	END;
END;
{End Sub}

{Subprocedure Drive_Dialog}
PROCEDURE EditHatch( ObjHand : HANDLE );
VAR
	bool : BOOLEAN;
BEGIN
	bool:=SetVectorFill (ObjHand,gHatchChoiceNew);
	ResetObject( ObjHand );
END;	
{End Sub}

{MAIN}
BEGIN
gHatchCount := BuildHatchList;
gDlogID := Define_Dialog;
gOKdlog := VerifyLayout(gDlogID);
IF gOKdlog THEN gDlogResult := RunLayoutDialog(gDlogID,Drive_Dialog);
IF (gDlogResult = 2) THEN alrtdialog('You canceled') ELSE
BEGIN
	gCrit:=ConCat('HFI=',Chr(39),gHatchChoiceOld,Chr(39));
	ForEachObject(EditHatch,gCrit);
END;
END;
Run(ImagePopTest);

Share this post


Link to post

Another time "WOW"

you are great,

i think i will need monthss to understand that,

but i will try.

Thanks to your nice written code,

i can understand at least a little bit...

Dank je well

mika

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
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.

×