Jump to content

Excel Roombook to rectangles and multistamp


leisure

Recommended Posts

Hi everyone 🙂

I am trying to write rectangles with an attached multistamp from an excel-roombook into vectorworks.
 

My excel looks like this:

image.png.0bb9ee0c51ae7bf64e0750d7c1a89ff3.png

 

It is my goal to create rectangles in the given size with an attached Multistamp-Object which works like this:

image.png.96aa5d081837a08bdaea3563f767a7e1.png

 

Actually I did not find a way to place a MultiStamp at all. I only found a way to place a rectangle and tried to place a datastamp-object instead, but it doesn´t work 😞
 

import vs

origin = [0, 0]
direction = [0, 1]
width = 5
height = 2

rec = vs.RectangleN ( origin[0], origin[1], direction[0], direction[1], width, height )

hDataTag = vs.GetObject('Test_2')
vs.DT_AssociateWithObj(hDataTag, rec)

 

Actually I get the following error. I am using Vectorworks 2019.

image.png.860cee35d6fb2e9f68ce368d88ac6479.png

 

image.png

Edited by leisure
Link to comment

@leisure,

   I am not sure why vs.DT_AssociateWithObj() is not recognized as it is working on my machine, but there is a problem earlier in your script. vs.RectangleN() does not return a handle. You must get its handle by using vs.LNewObj().
 

vs.RectangleN ( origin[0], origin[1], direction[0], direction[1], width, height )
rec = vs.LNewObj()

 

After you make the above change, if you still get an error with vs.DT_AssociateWithObj() not being recognized, please write back.

 

Raymond

Link to comment
  • 2 weeks later...

Hey thanks a lot Raymond,

 

do you know if there was any option like that in VW 2019? I checked back with my office management and there is to no real possibility to upgrade to a newer version.

 

Is there a way to find the "API" of the older versions like apidocs.co for Revit / Rhino / Navisworks?

 

And is there a way to write custom DataTagInfos when a tag is placed like "Roomnumber"?

 

vs.RectangleN ( origin[0], origin[1], direction[0], direction[1], width, height )
rec = vs.LNewObj()

vs.GetObject('Test_2')
hDataTag = vs.LNewObj()

vs.DT_AssociateWithObj(hDataTag, rec)

// Fill custom object parameters
hDataTag.SetParameter("Roomnumber","101.01")

 


Kind regards,
Jannis

Edited by leisure
Link to comment

Hi @leisure,

   I don't think there was any command in VW 2019 of a similar nature. It is not a command I have ever used, so I don't know if there is another way to make the association. If it is possible, hopefully someone else will chime in with their insight. Or, you could contact Tech Support to see if you can get an answer from VW Engineering.

 

   Yes, there is an online Script Reference at Script Function Reference. It is organized by category (list shown on the right sided of the page), so if you don't know the category of your command, use the Search field at the top of the page to locate it. Also, there is a similar HTML copy that ships with your software, but it is limited to the calls found in you version and older. You can find it in the VW Application folder under /VWHelp/Script Reference/ScriptFunctionReference.html. I usually use the HTML version first, then if I can't find the function, or I think there may be more information available, I check the online version.

 

   At the top of each command in the HTML version, the "Born On Date" is listed to the right of the command name. In the online version, it is listed at the bottom, under the section titled Version. If the function has been deprecated, that "date" is also listed. By "date" I mean VW version.

 

HTH,

Raymond

Link to comment

Hi @leisure,

   In your example above, your first two lines appear to be syntactically correct, but the rest are not. Originally, I think you had the first two correct.

 

vs.GetObject('Test_2')
hDataTag = vs.LNewObj()

should still be:

hDataTag = vs.GetObject('Test_2')

but this assumes there is a Data Tag on the drawing with the name 'Test_2'. If 'Test_2' is a name to another VW object, you'll get a handle to some other object type. You might want to test the handle you get to ensure it is a PIO instance (type = 86), and that the name of the PIO your handle points to is 'Data Tag'.

 

 

But, if you are wanting to PLACE a Data Tag, then you need to use:

hDataTag = vs.CreateCustomObject('Data Tag', X, Y, 0)

Note vs.CreateCustomObject() returns a handle so you do not need to use vs.LNewObj().

 

 

and the 5th line returns a boolean, so you might write it like:

if vs.DT_AssociateWithObj(hDataTag, rec):
	hDataTag.SetParameter("Roomnumber", "101.01")	# Fill custom object parameters

assuming the hDataTag.SetParameter() line is syntactically correct, but I doubt Handles have the attribute "SetParameter". If I were to guess, I think you have to access the PIO's record with SetRField() and access the right parameter, but I'm guessing here as I've never played with Data Tags.

 

HTH,

Raymond

  • Like 2
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...