Jump to content
Developer Wiki and Function Reference Links ×

Drawing coodination switch not working during script


The Hamma

Recommended Posts

I wrote a script to renumber viewports but I get a warning that the number has been used before.  If Drawing coordination is turned off they no warning is displayed.  So I tried to turn it off in the script and turn it back on at the end but it still gives the warning.  Test file attached. 

 

{Script Name: VP Label (Consecutive)

This script will renumber drawing labels contained within VP annotations in order picked by mouse. 

David Hamer, 2022 revision 11/7/2022}


PROCEDURE NumberVPConsecutive;

VAR	
   numberStr : STRING;
   h,h2, anno, h1 : HANDLE;
   pX,pY : REAL;
   doorNumber,dummyVar,vpNumber : INTEGER;
   zoomis:LONGINT;
   DCPref:BOOLEAN;

PROCEDURE SetVPNumber;
BEGIN
GetPt(pX,pY);
  	if GetTypeN(h) = 122 THEN BEGIN {if h is a viewport}
		anno := GetVPGroup(h, 2); {creates group from annotations of selected viewport}
		h1 := FInGroup(anno); {selects the first object in the anno group}
		while h1 <> NIL DO BEGIN { steps through every object in the viewport selected by the click}
			if GetObjectVariableString(h1, 1166) = 'Drawing Label' THEN BEGIN {if veiwport object is a drawing label}
				SetRField(h1,'Drawing Label2','Drawing',numberStr); {VW 2021 Version sets the drawing label to the current active number in sequence}
				vpNumber := Str2Num(numberStr); { convert number string to number.}
				numberStr := Num2Str(0, vpNumber + 1); {subtract number from sequence then convert number to string.}
				ResetObject(h1);
			END;
			h1 := NextObj(h1); {get next object in viewport\}
		END;
		ResetObject(h);
	END;
END;

BEGIN
DCPref := GetPref(544);{get status of drawing coordination}
SetPref(544,FALSE);{turn off drawing coordination}
ReDrawAll;
{•••• Ask for starting number ••••}
numberStr := StrDialog('Enter and INTEGER to start numbering:','1');
Message('Click in empty space to end numbering');
SetVPNumber;
  {•••• Repeat process until there is NO object at the clicked location ••••}
  WHILE GetPickObjectInfo(pX,pY,h,h2,dummyVar) DO BEGIN
    SetVPNumber;
  END;
ClrMessage;
{ReDrawAll;}
SetPref(544,DCPref);{set drawing coordination to original state}
zoomis:=GetZoom;
SetZoom(101);
Setzoom(zoomis);
END;

RUN(NumberVPConsecutive);

 

vp renumber.vwx

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