Jump to content
Developer Wiki and Function Reference Links ×

Error message.


Recommended Posts

Can someone tell my why I'm getting an error on line 41, the SetName function.  The script still does what it is supposed to do after dismissing the error message.

 

This is an example of the error I get when one VP on a sheet layer is selected:

 

591cea2325d7b_ScreenShot2017-05-17at5_22_04PM.png.f9b30913198a706c9521354f8bd81d9a.png

 

Procedure ViewportRename;

{Badly Scripted by Michael Klaers.  Updated Aug 2, 2015}

{This script will take all selected viewports and change the name of those viewports to be

		(Sheet Layer) (Drawing Number) (Drawing Name)

This version tries to force the name to appear immeidately in the name field, data tab, OIP when only one VP is selected.

Prior to this version the new name appeared immediately in the Nav Palette, but not in the name field.}


	Var
	VPDwgTitle,VPName,BText,VPNum : String;	
	h,hh:  Handle;
	ViewportLayer: Handle;
	ViewportLayerString: String;

	
	


	Procedure RenameVP(h : HANDLE);
Begin							{***********  BEGIN Procedure  ***********}	
	ViewportLayer:= GetLayer(h);
	ViewportLayerString:= GetLName(ViewportLayer);
	VPDwgTitle := GetObjectVariableString(h, 1032);
	VPNum := GetObjectVariableString(h, 1033);
	ResetObject(h);


{	Message('Viewport Handle: ',h,chr(13), 
			'Layer Handle: ',ViewportLayer,chr(13),
			'Layer Name: ',ViewportLayerString,chr(13),
			'VP Num: ',VPNum,chr(13),
			'VP Name: ',VPDwgTitle);
}


	SetName(h, CONCAT(ViewportLayerString,' ',VPNum,' ',VPDwgTitle));

	SetDSelect(h);		{These two commands are just here to force the new name to appear in the }
	SetSelect(h);		{name field immediately.  They can be deleted w/o consequence}

End;							{***********  END Procedure  ***********}



Begin							{***********  Main Program  ***********}	

	ForEachObject(RenameVP,(((T=VIEWPORT) & (SEL=TRUE))));

End;

Run(ViewportRename);




Any ideas?

 

Thanks!

 

mk

Link to comment

That makes sense. Names have to be unique and unused, even if re-naming an object with its own name. If you run the script once, you have already assigned the name to the objects, and you will get errors in the second run. 

 

You can check to see if an object already has the name before assigning. You should also check that the proposed name is unique -- Name2Index = 0 -- and decide what to do if the name isn't unique. 

 

-Josh

Link to comment

Thanks Josh and Patrick.

 

Just for my own understanding:  Why was the script kicking back errors on random viewports on other sheet layers?

 

Are they selected but not in the active sheet layer and therefore the script is trying to include it?

 

Should I add a criterion to make sure I only include the active sheet layer?

 

 

mk

Edited by michaelk
Grammar pedantry is a terrible thing.
Link to comment
2 hours ago, michaelk said:

Just for my own understanding:  Why was the script kicking back errors on random viewports on other sheet layers?

 

Are they selected but not in the active sheet layer and therefore the script is trying to include it?

 

Should I add a criterion to make sure I only include the active sheet layer?

Yes and Yes.  If you only want to work on viewports you can see you should definitely add a criteria for the active layer. Which is kind of a pain since the criteria only work by Layer Name so you have to get the name and then use that in the criteria.

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