Jump to content

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.

Link to comment
  • 2 months later...

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/

 

 

 

Link to comment

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 2
  • Love 1
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...