Jump to content
Urstanner

Script for Automatic filling of fields

Recommended Posts

Hello together
I need help with Python scripts.
I would like to create a Python script, which should have the following function:
The Python script should read the numerical values from a text file into the Vectoworks Interiorcad. The values should then be inserted automatically into the fields of the Info palette of the VW Cabinet manager.
Is there such a possibility with the Vectoworksworks Interiorcad program?

Thank you very much for your help.

Share this post


Link to post

Hi Urs

The short Answer: Sure, this is possible but maybe not possible for a first scripting exercise. You can load data from a Textfile and you can attach Data to a PlugIn Object.

I also pretty sure this question was asked for another plugIn (PlugIn is PlugIn A window and a cabinet makes not difference) before in the forum.

 

 

Where to start:

- What is the exact result you want to have. You want to create as example 1000 PIOs as Symbols from an external file?

- Do you want to read a textfile and attach the values to a PlugIn Object in the drawing? Why you want to do this?

- Do you know the Vectorworks Data Sheet? You could list your PluIns and change values in the Data Sheet or paste it from external list.

 

So the start would be to know exactly what the final result should be and which workflow now seems not fast enough to invest time in a script.

 

Similar Projects:

Maybe take a look in the Marionette Corner. If you want a textScript, you can learn from the code inside the nodes, it is the same.

 

1. Import a text File:

https://forum.vectorworks.net/index.php?/files/file/116-create-record-from-external-file/

 

2. How to create PlugIns from such a list

https://forum.vectorworks.net/index.php?/files/file/81-spacesfromlistvwx/

 

3. Create a Symbol

https://forum.vectorworks.net/index.php?/files/file/120-create-symbol/

 

 

 

Share this post


Link to post

There is a Script on the "VSSM Vorgabe.sta" which changes Title Blocks from an external File. If you create your vwx in an external software you can attach a txt which contains this data. With the same system, you can attach data for other PlugIns (like the cabinet you use). So you maybe define your cabinet in the external software, then click there on a button which creates the vwx (from different templates maybe) which contains your cabinet. Then Double click the script and set the dimensions of your cabinet to the exported values. 

 

Can save some seconds for your drawing. Seems like this is the kind of script you want to have. Not have much time for this (I think after a answer of your initial question you would like to create more than one cabinet per file or maybe want to attach other kind of date (which is not part of the Object Info Palette and which we maybe can change or maybe not like Position Number and stuff like this ).

Maybe you could use Layer Name for position Numbers and export the layer name with a custom cutting list export configuration. I can give you a start with the following script (Filename.vwx and Filename.txt in the same Folder) then the Columns "Breite", "Hoehe", "Tiefe" which are translated to a dictionary you can easy call in the script. This Example will change the first object in the Layer (which maybe not suffice but it is just an example not a solution).

 

The better you can descripe any details and specifications and post examples and previous work the better you will get answers from the community. If you invest some of your time you maybe are able to change some part of a relatively simple script like this.

 


pathVWFile = vs.GetFPathName()
path = pathVWFile[:-3]+'txt'

skipHeader = False
asString = True
delimiter = "\t"
codex = 'iso8859_2'#'latin_1', 'iso8859_2', 'mac_latin2','utf_8'

lines = []
rows = []
import csv
import os
if asString==False:
	quote = csv.QUOTE_NONNUMERIC
else:
	quote = csv.QUOTE_NONE

if os.path.isfile(path) == False:
	vs.AlrtDialog('Importdatei wurde nicht gefunden')
	
#vs.AlrtDialog(path)
	
rowNum = 10
lineNum = 10



if os.path.isfile(path) ==True:
	with open(path, encoding=codex) as f:
		reader= csv.reader(f,dialect='excel',delimiter=delimiter,quoting=quote)
		if skipHeader==True:
			next(reader)
		for line in reader:
			lines.append(line)
		lineNum = len(lines)	
		rowNum = len(line)			
		for row in range(rowNum):
			rown = []
			for line in range(lineNum):
				rown.append(lines[line][row])		
			rows.append(rown)


	if asString == False:
		rows = tuple(tuple(x) for x in rows)
		rows = list(rows)	
		lines = tuple(tuple(x) for x in lines)
		lines = list(lines)

erpdict = dict(zip(lines[0], lines[1]))
h = vs.FActLayer()
Record = 'XG Cabinet'
#vs.AlrtDialog(str(erpdict))

vs.SetRField(h, Record, 'Width', erpdict.get('Breite'))
vs.SetRField(h, Record, 'Height', erpdict.get('Hoehe'))
vs.SetRField(h, Record, 'Depth', erpdict.get('Tiefe'))

vs.ResetObject(h)

 

 

 

KorpusmöbelExterneDatenquelle.zip

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×