Jump to content
Developer Wiki and Function Reference Links ×

change hatch fill via script


myf

Recommended Posts

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

Link to comment

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
Link to comment

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);

Link to comment

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!

Link to comment

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);

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