VS:DBObjSQLGetRead

From Vectorworks Developer
Jump to: navigation, search

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix


Description

Get an object's SQL query for ODBC read.
FUNCTION DBObjSQLGetRead(
hRecord  :HANDLE;
VAR SQLSentence  :DYNARRAY[] OF CHAR) : BOOLEAN;
def vs.DBObjSQLGetRead(hRecord):
    return (BOOLEAN, SQLSentence)

Parameters

hRecord HANDLE
SQLSentence DYNARRAY[] of CHAR

Example

VectorScript

PROCEDURE Test;
VAR
	recordName, query : DYNARRAY [] OF CHAR;
	hCurrentLayer, hCurrentObject, hRecord : HANDLE;
	i, cnt : LONGINT;
	res : BOOLEAN;

BEGIN
	hRecord := NIL;
	{Select only objects with record attached}
	recordName := 'TestRecord';
	DSelectAll;
	SelectObj(INSYMBOL & INVIEWPORT & (R IN [recordName ]));

	{Get quesries of selected object}
	hCurrentLayer := FLayer; { first layer }
	WHILE (hCurrentLayer <> NIL) DO { loop through all the layers }
	BEGIN
		hCurrentObject := FSObject(hCurrentLayer); { first selected object in layer }
		WHILE hCurrentObject <> NIL DO { loop through all the objects }
		BEGIN
			{find the record}
			cnt := NumRecords(hCurrentObject );
			FOR i := 1 TO cnt DO 
			BEGIN
				hRecord := GetRecord(hCurrentObject , i);
				IF hRecord <> NIL THEN BEGIN
					IF GetName(hRecord) = recordName THEN BEGIN
						res := DBObjSQLGetRead(hRecord, query); 
						AlrtDialog(query);
					END;
				END;
			END;
			hCurrentObject := NextSObj(hCurrentObject); { next selected object }
		END;
		hCurrentLayer := NextLayer(hCurrentLayer); { next layer }
	END;
	
END;
RUN(Test);

Python

import vs

def Test():
	hRecord = vs.Handle()
	#Select only objects with record attached
	recordName = 'TestRecord'
	vs.DSelectAll()
	vs.SelectObj("INSYMBOL & INVIEWPORT & (R IN ['" + recordName + "'])" )

	#Get quesries of selected object
	hCurrentLayer = vs.FLayer() #First Layer
	while hCurrentLayer != vs.Handle(): #loot through layers

		hCurrentObject = vs.FSObject(hCurrentLayer) #first selected object
		while hCurrentObject != vs.Handle(): #loop through all the objects

			#find the object
			cnt = vs.NumRecords(hCurrentObject)
			for i in range(0,cnt):

				hRecord = vs.GetRecord(hCurrentObject, i + 1)
				if hRecord != vs.Handle():
					if vs.GetName(hRecord) == recordName:
						res, query = vs.DBObjSQLGetRead(hRecord)
						vs.AlrtDialog(query)

			hCurrentObject = vs.NextSObj(hCurrentObject)
		
		hCurrentLayer = vs.NextLayer(hCurrentLayer)


Test()

Version

Availability: from Vectorworks 2011
Personal tools
NamespacesFFFF

Variants
Actions
Advanced Search
See Also
Navigation
Toolbox