Jump to content

How to set a NEW class

Recommended Posts


I'm unable to set the proper class to a new obj.

What's wrong with this?

In my opinion, it a very, very simple script, but what I get is not what I need: create a closed parametric polygon (ok) to a class...

Thank you




VW 2017 SP1

Here's the script.


    {capitalized to distinguish them from variables}
    layerHandle, objectHandle:handle;

    {objectHandle := LNewObj;                    <--------  I've tried this way but it doesn't works too
    SetClass(objectHandle, 'MyObj');}

Edited by lucioing

Share this post

Link to post

It works for me. I added constants for PH1, PH2, PL1, PL2.


When I run the script for the first time it creates a class named MyObj, makes that the active class and creates the new object in that class.


What are you seeing?


Share this post

Link to post

I think it doesn't works on 2017 SP1, because this simple code runs under 2015 but doesn't under 2017 SP1


Procedure MyRect;



RUN (MyRect);


So, I'm unable to understand why!

Anyway, Pat, thank you for your reply.



Share this post

Link to post

Ok, I'm getting crazy! 

New installation VW2017+SP1.

Nothing, it doesn't works.

Here's a screenshot





Share this post

Link to post

Ok, got it!

It depends on the 'type' of plugin. Here's a picture.

It seems that 'point obj' doesn't works correctly, as shown...






Share this post

Link to post

I've tryied an old plugin I wrote some years ago... If I define it as 'Point tool', it doesn't works.

I've also export an object created straight in VW (2017) and it is the same!

Please, let me know about...







Share this post

Link to post

So in a PIO the class MyClass is being created, but the object is not being assigned to that class. The Rectangle inside the "container object" that is the PIO is assigned to MyClass, but the PIO instance is not. Ungroup the PIO to see the rectangle and the class.


Everything that happens inside the PIO is basically hidden from the rest of the drawing functions. It kind of runs in its own special space and then the result is drawn in the correct place in the VWX drawing.


Since you are changing the class inside the PIO routine, this class change only effect objects drawn inside the PIO and not the PIO container or the active class after the conclusion of the PIO regeneration.


I can't think of a work around right now, but I will sleep on it and see what I can come up with.


Share this post

Link to post
52 minutes ago, JBenghiat said:

The quick version:


Use GetCustomObjectInfo() to get a handle to the currently executing PIO.



Use SetClass() to set the class of the PIO itself.


Note, the PIO will always be in this class.  Setting the PIO's class on first insertion is possible but a little more complex.



Great jbenghiat!

I never though to this! Thank you so much!



Share this post

Link to post

Here's the code.

Thank you again! :D




Procedure MyRect;

    objectName : STRING;
    objectHand, recordHand, wallHand : HANDLE;
    b: BOOLEAN;
        b:=GetCustomObjectInfo(objectName,objectHand, recordHand, wallHand);
        SetClass(objectHand, 'MyObj');
Run (MyRect);

Share this post

Link to post

One thing to note here, using NameClass() also sets the active document class to 'MyClass'.  You have two ways around that:

1. Use ActiveClass() to set a variable to the current class and then use NameClass( savedClass ) at the end of the script to restore.

2. Use PushAttrs / PopAttrs to save and then restore current settings.



Share this post

Link to post

NameClass does not seem to set the overall active class in the document when it is used inside a PIO. It does change the class in the PIO and all the objects that are created after NameClass in the PIO are set to that class, but the PIO itself is placed in the class that was active when the PIO was created and the Active Class in the document remains unchanged.

Share this post

Link to post

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.


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.

  • Create New...