nanoCAD Platform Help

Object versioning support

The object versioning is necessary in order for the new parameters in the updated object to be correctly displayed and used on the previously inserted objects.

The seted protected parameter is used to support the object versioning. The parameter is automatically generated when using the script wizard and can be renamed or added manually if necessary.

Consider the script for creating a rectangle (the script is not complete, only methods relevant for the example are shown):

	...
function ActHeader {
	NPart=0;
	Public(a,"Length", b,"Width");
	Protected(seted);
	Changeable(a,b );
	OnDlgBeforeSelectParam = 0;
	ShowWhenSelPnt = 1;
	ContourOnLine = 0;
};
	...
function OnInitialization {
	if(seted == UnknownValue) {
		seted=1;
		a = 100;
		b = 100;
	};
};
	...
function OnDialog {
	UniDialog( VFLD, a,"Length", b,"Width", TVIDS,lViewType,"All",VIEW,"Vids");
};
	...

The ActHeader method specifies the seted protected parameter and the public length and width parameters.

In the OnInitialization method for an object that has no version, add the length and width parameters and set version 1.

In the OnDialog method, we call a dialog with the width and length fields.

 

Let's insert an object (hereinafter Object1). When placing an object on a drawing, a window with default parameters will open.

CAD drafting Object versioning support 0

 

Suppose we need to add line thickness for the rectangle.

To do this, we add the "weight" parameter:

	...	
Public(a,"Length", b,"Width", weight, "Weight");
	...
function OnInitialization {
	if(seted == UnknownValue) {
		seted=1;
		rZOrder=100;
		a = 100;
		b = 100;
		weight=1;
	};
};
	...
function OnDialog {
	UniDialog( VFLD, a,"Length", b,"Width",weight,"Weight"  TVIDS,lViewType,"All",VIEW,"Vids");
}; 
	...				
					

 

Let's insert an object (hereinafter Object2). The dialog correctly displayed the line weight to us.

CAD software Object versioning support 1

 

Let's open Object1 for editing and see that the "Weight" parameter is displayed incorrectly.

CAD drawing Object versioning support 2

The point is that Object1 already has version (seted) 1 and the weight is not assigned.

Let's fix the OnInitialization method. If there is no version, we will increase it to 2, add a condition if we have version 1.

function OnInitialization {
	if(seted == UnknownValue) {
		seted=2;
		rZOrder=100;
		a = 100;
		b = 100;
		weight=1;
	};
	if(seted == 1) {
		seted=2;
		weight=1;
	};
};

Now objects of older versions will open correctly.

CAD drafting Object versioning support 3