Jump to content

Plug-in script drawing a new object on file open

Recommended Posts

I am sure this is something simple, but I can't figure it out. It has happened for several years with this plug-in script over several versions of VW. 


It is part of a set of scripts that I created for a designer's custom cabinet line. The script reads information from one worksheet, combines that info with info in a second worksheet to draw an elevation of cabinetry. The second worksheet is a fairly large spreadsheet of the designer's "standard" cabinetry and the relevant parameters for each type of cabinet. The first worksheet is the list of cabinets and their sizes for a particular job.

I have both a plan section plug-in and an elevation plug-in that read the job specific worksheet rows I set in the object property window, to draw each wall of cabinetry. Other scripts break down the final approved drawings into a spreadsheet of cabinet parts that gets fed to a CNC. 


To be clear, these plug-in scripts are not elegant. I am a novice programmer on my best day and I have learned a ton since creating them. But all of them have functioned adequately for years. 


However, the elevation drawing plug-in...always...creates a new elevation when a file is opened in which I have used that plug-in.


If I saved and closed the drawing file with a design layer open, when I open the file again, it will place an elevation at 0,0 in that design layer. If I saved and closed the file with a sheet layer open, it will place a full scale elevation over the sheet layout. 


Two things that make this more strange, at least to me.


a) as I mentioned, the plug-in is set so that I specify Worksheet "A",  row "X" thru row "Z" - for each elevation (or plan section). So, when I first use the plug-in it will either not draw anything or something incorrect, until I get the parameters correct in the object property window. The weird part is (or perhaps the telling part?), the elevation it creates on file open seems to always be the first elevation it drew with correct parameters, or perhaps a better way to put it, the first elevation it drew that is still in the file. Not the first thing it tried to draw with no or wrong information referenced, but a copy of the first elevation in the drawing. 


b) this new elevation created at file open is always converted to individual objects, not even a group, by the time the file is fully opened - basically lines, rectangles, loci, and text, in the correct classes - but no dimension objects. 


It is only an annoyance and I have gotten so used to it that when I open a file, I automatically find the new elevation, delete it and go about my work.

But things are changing. I will likely be modifying and simplifying this drawing process, and then creating the CNC files in Microvellum going forward. So I thought I would see if someone might have an idea where to start to look for issues that could cause this.


Thanks for any help,  



VW2020 - Designer - Windows10



Link to comment

It is really hard to make any suggestions without seeing the code.

Basically, a PIO is a script that recalculates based on events such as moving, rotating, or resizing the object. But one of the redraw events is also for drawing the object when the file is first opened.

It sounds as if the drawing code is running before the parameters for the object are set and is using the defaults. What happens with a file that has more than one of your PIO objects in it? Do you get multiple extra elevations, one for each instance of the PIO?

See if you can figure our where the initial drawing with the defaults it occurring. Of just put most of your code into an IF statement so it does not run unless it has good values for the parameters.



Link to comment

Thanks Pat, 

That is the weird part. It creates one pio object (an elevation) on file open. There could be 5 or 10 elevations, all pio created objects with the same script, in the file - all still pio objects that I can modify by changing their parameters - ie: not converted to a group, etc.  


Sorry if I am only repeating and not making myself clearer here....


It seems to - I would say always, but I can't say I have always paid attention - draw a copy of the first created pio object that is still in the file.

It only creates the one copy of the one object.

It puts it at the origin of the active layer when the file was saved - design or sheet. 

The actual elevations I create with that pio are almost never at an origin. 

If I leave this created elevation in the file, save and close the file with the same layer open, it will put another identical copy on top of the last when I open it again. 


This created elevation is also being exploded, to use an autoCAD term, into components - not even converted to a group. So what I am left with is a 2D elevation of lines and rectangles, text and loci, that is no longer a pio object in any way.


Perhaps even weirder - the dimensions that are part of the PIO wont be there.


The objects created will be selected...so that I can simply "fit to objects" to find them and hit delete to get rid of them...EXCEPT the loci (the pio places loci to help when I am snapping to points in the elevation). It is as if it creates copies of the Loci. The copies will not be selected and will be sitting there after I delete the rest, so that I have to select them and delete them separately.


I have taken two screen captures to help illustrate. In the PIO Elevation 1.jpg - the orange highlighted lines are the first instance of the pio object created in the file. The upper cabinets are also done with the same tool, but are a different instance of it, and there are several more. The second image is what I get in the file when I open it up...found at the origin of this layer, nowhere near the other drawings nor where the view is set at file open. And the objects are selected. 


This may be a clue too. I just found that this does not happen if I simply close a file and reopen it. It only happens if I shut VW down and restart it, before reopening the file. I never realized that before. 


I am happy to give you the script but I am afraid I would need to also provide aspirin for the headache reading through it may cause. It is fairly long, not elegant as I mentioned, and likely poorly annotated for someone looking to figure out what the hell sean was doing.


Right now it is a "find, delete, move on" issue - and will stay that way if it doesn't go away when I modify the script. Not a big deal and its only me that has to deal with it at all. I spent more time typing this than deleting the objects has cost me in total.  

I just hoped someone would say, something like: "I had that happen. I changed X and it went away." 

But if you are looking for a puzzle, let me know and I will send it along. 


Thanks again, 


PIO Elevation 1.jpg

PIO Elevation - at file open.jpg

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.

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...