Jump to content
The Hamma

Construction Phasing Data Visualization (Existing, Demo, New, NIC)

Recommended Posts

Posted (edited)

Revised 08-13-2020

    See revision note in new comments

 

Attached are scripts that I wrote to help with renovation projects. 
These scripts edit the classing and add a construction phase record to every item selected. 

PIO's that are inserted in walls can be selected with out selecting the containing wall and the script will only affect those PIO's selected.  If the wall is selected it will modify the wall and the PIO's that are contained with in that wall. 
  

SCRIPT                              CLASS MODIFICATION                                   CONSTRUCTION PHASE RECORD    

1 Existing Object              1_Exist- (Prefix)                                                 EXISTING TO REMAIN    

2 Demo Object                  2_Demo- (Prefix)                                               DEMOLISH EXISTING      

3 New Object                    No change or return to original Class            NEW CONSTRUCTION   

4 NIC Object                      No change or return to original Class           NOT IN CONTRACT

5 Remove Phase Record  No change or return to original Class          REMOVES RECORD FROM SELECTED OBJECTS  (ADDED)


With the use of the scripts and data visualization you can create viewports that show the construction phases as desired. 

 

Attached to this post is a demonstration Video, the two files used in that video, and the four scripts.  I added the script to my selected object context menu so when I right click on an object I can access the scripts from there. 

 

 

 

 

 

Construction Phase Demo Unmodified Plan.vwx Construction Phase Demo.vwx

1 Existing Object.vsm 2 Demo Object.vsm 3 New Object.vsm 4 NIC Object.vsm 5 Remove Phase Record.vsm

Edited by The Hamma
  • Like 4

Share this post


Link to post
Posted (edited)

Script has been modified to detect if Design Layers or Sheet Layer is active and Isolate modifications to the active layer type.  Also added the ability to modify objects within a Sheet Layer or Sheet Layer VP annotations.  Note that classes will need to be enabled in VP dialog after running script in VP annotations otherwise they may be hidden.  Only works on objects inserted in walls when design layer is active. 

 

"""
This script assigns selected objects to class "1_Exist-(original class)" and set Construction Phase to 'EXISTING TO REMAIN'.

If a in wall object is selected without selecting the wall the script will only change those in wall objects.
If a wall is selected it will change the wall and all objects inserted in that wall.
If New class does not exist objects original class is duplicated to retain class attributes.

To take full advantage of this script use "Data Visualization" to display the "Construction Phase"
  record objects as desired.
     1. Set "Data Visualization" to modify drawings per "Construction Phase" record
     2. To make a "Construction Phase" invisible set the attributes of that phase to:
           Line settings to Fill "Solid White" and Line weight "0"

This Python Script may be freely distributed. No warranty provided.
Use at your own risk.

Vectorworks bug does not show changes to symbols inserted in wall until either:
   Drawing is saved and reopened.
   Setting in Data Visualization dialog is changed.
   Symbol is removed from wall, can then be reinserted

David Hamer, 2020 revision 07-15-2020
"""

# Modifications to any objects happen here
def assign(h):
    CName = vs.GetClass(h)
    CLen = vs.Len(CName)
    CNameE = vs.Copy(CName, 1, 8)  # Grab First 8 letters of handle's class
    CNameD = vs.Copy(CName, 1, 7)  # Grab First 7 letters of handle's class
    if CNameD == '2_Demo-':  # Check if first 7 letters equal '2_Demo-'
        CName = vs.Copy(CName, 8, CLen)  # if true grab root name of class
    # check if the class is new, if so delete new class and duplicate objects class and rename.
    if CNameE == '1_Exist-':
        CNameN = CName
    else:
        CNameN = vs.Concat('1_Exist-', CName)  # If not add '1_Exist-' to name
    ClassCount = vs.ClassNum()  # determine number of classes in drawing
    vs.NameClass(CNameN)  # set the name of the class to be applied to handle if new class will be created
    if ClassCount + 1 == vs.ClassNum():  # check if the class is new and if delete new class and duplicate source
        vs.ReDraw()
        vs.DelClass(CNameN)  # Delete new class
        CHandle = vs.GetObject(CName)  # get handle to source class
        NDCHandle = vs.CreateDuplicateObject(CHandle, vs.GetParent(CHandle))  # duplicate source class
        vs.SetName(NDCHandle, CNameN)  # rename duplicate class to name to be applied to handle
        vs.ResetObject(NDCHandle)
        vs.ResetObject(h)
    vs.SetClass(h, CNameN)  # name handle's class
    vs.SetRecord(h, 'Construction Phase')  # add record to inserted object
    vs.SetRField(h, 'Construction Phase', 'Phase', 'EXISTING TO REMAIN')  # modify record to inserted object

 # Passes Handle to "def assign(h):" of PIO or Symbol selected
def pio_processing(h):
    global container  # declare global variable to be retained
    if vs.GetObjectVariableInt(vs.GetLayer(h), 154) == activetype:
        assign(h)  # Runs "def assign(h):"
        hParent = vs.GetParent(h)  # Get Parent handle
        itParent = vs.GetTypeN(hParent)  # Get Parent type
        if itParent != []:
            if itParent == 68:  # If Parent type is a wall set container to state PIOinwallwasdetected
                container = 'PIOinwallwasdetected'
            if itParent == 89:  # If Parent type is a round wall set container to state PIOinwallwasdetected
                container = 'PIOinwallwasdetected'

# Passes Handle to "def assign(h):" of every object except PIO and Symbols outside walls selected
def object_processing(h):
	if vs.GetObjectVariableInt(vs.GetLayer(h), 154) == activetype:
		assign(h)  # Runs "def assign(h):"
		h1 = vs.FIn3D(h)
		while h1 != []:
			if vs.GetObjectVariableInt(vs.GetLayer(h1), 154) == activetype:
				if vs.GetTypeN(h1) == 15:
					assign(h1)  # Runs "def assign(h):" on symbol inserted
				if vs.GetTypeN(h1) == 86:
					assign(h1)  # Runs "def assign(h):" on PIO inserted
			h1 = vs.NextObj(h1)

def sl_processing(h): # Omit's Viewports in Sheet Layers
	if vs.GetTypeN(h) != 122:
		assign(h) 

activetype = 1
container = 'none'  # Declare container var
ACName = vs.ActiveClass()  # Record name of active class
if vs.GetObject('Construction Phase') == ():  # Creates "Construction Phase" record if not present
	vs.NewField('Construction Phase', 'Phase', '<none>', 4, 0)
	
if vs.GetObjectVariableInt(vs.ActLayer(), 154) == 2:
	activetype = 2
	vs.ForEachObjectInLayer(sl_processing, 2, 0, 0)
else:
    # Passes Handle to "def pio_processing(h):" of PIO and Symbols selected
    vs.ForEachObject(pio_processing, "((((T=PLUGINOBJECT)|(T=SYMBOL)) & (V) & (SEL=TRUE)))")

    # Passes Handle to "def object_processing(h):" of objects selected except PIO and Symbols outside walls selected
    # Skipped if PIO or Symbol selected was in wall
    if container != 'PIOinwallwasdetected':
        vs.ForEachObject(object_processing, "(((T<>PLUGINOBJECT)&(T<>SYMBOL)&(T<>VIEWPORT) & (V) & (VSEL=TRUE)))")

vs.NameClass(ACName)  # Return active class

 

Edited by The Hamma

Share this post


Link to post
Posted (edited)

Script has been edited to omit objects selected on layers that are visible but not editable because layer options are not set to "Show/Snap/Modify Others"

 

"""
This script assigns selected objects to class "1_Exist-(original class)" and set Construction Phase to 'EXISTING TO REMAIN'.

If a in wall object is selected without selecting the wall the script will only change those in wall objects.
If a wall is selected it will change the wall and all objects inserted in that wall.
If New class does not exist objects original class is duplicated to retain class attributes.

To take full advantage of this script use "Data Visualization" to display the "Construction Phase"
  record objects as desired.
     1. Set "Data Visualization" to modify drawings per "Construction Phase" record
     2. To make a "Construction Phase" invisible set the attributes of that phase to:
           Line settings to Fill "Solid White" and Line weight "0"

This Python Script may be freely distributed. No warranty provided.
Use at your own risk.

Vectorworks bug does not show changes to symbols inserted in wall until either:
   Drawing is saved and reopened.
   Setting in Data Visualization dialog is changed.
   Symbol is removed from wall, can then be reinserted

David Hamer, 2020 revision 08-13-2020
"""


# Modifications to any objects happen here
def assign(h):
    CName = vs.GetClass(h)
    CLen = vs.Len(CName)
    CNameE = vs.Copy(CName, 1, 8)  # Grab First 8 letters of handle's class
    CNameD = vs.Copy(CName, 1, 7)  # Grab First 7 letters of handle's class
    if CNameD == '2_Demo-':  # Check if first 7 letters equal '2_Demo-'
        CName = vs.Copy(CName, 8, CLen)  # if true grab root name of class
    # check if the class is new, if so delete new class and duplicate objects class and rename.
    if CNameE == '1_Exist-':
        CNameN = CName
    else:
        CNameN = vs.Concat('1_Exist-', CName)  # If not add '1_Exist-' to name
    ClassCount = vs.ClassNum()  # determine number of classes in drawing
    vs.NameClass(CNameN)  # set the name of the class to be applied to handle if new class will be created
    if ClassCount + 1 == vs.ClassNum():  # check if the class is new and if delete new class and duplicate source
        vs.ReDraw()
        vs.DelClass(CNameN)  # Delete new class
        CHandle = vs.GetObject(CName)  # get handle to source class
        NDCHandle = vs.CreateDuplicateObject(CHandle, vs.GetParent(CHandle))  # duplicate source class
        vs.SetName(NDCHandle, CNameN)  # rename duplicate class to name to be applied to handle
        vs.ResetObject(NDCHandle)
        vs.ResetObject(h)
    vs.SetClass(h, CNameN)  # name handle's class
    vs.SetRecord(h, 'Construction Phase')  # add record to inserted object
    vs.SetRField(h, 'Construction Phase', 'Phase', 'EXISTING TO REMAIN')  # modify record to inserted object


# Passes Handle to "def assign(h):" of PIO or Symbol selected
def pio_processing(h):
    global container  # declare global variable to be retained
    if vs.GetObjectVariableInt(vs.GetLayer(h), 154) == activetype:
        hSEL.append(h)   # adds to list
        hParent = vs.GetParent(h)  # Get Parent handle
        itParent = vs.GetTypeN(hParent)  # Get Parent type
        if itParent != []:
            if itParent == 68:  # If Parent type is a wall set container to state PIOinwallwasdetected
                container = 'PIOinwallwasdetected'
            if itParent == 89:  # If Parent type is a round wall set container to state PIOinwallwasdetected
                container = 'PIOinwallwasdetected'


# Passes Handle to "def assign(h):" of every object except PIO and Symbols outside walls selected
def object_processing(h):
    if vs.GetObjectVariableInt(vs.GetLayer(h), 154) == activetype:
        hSEL.append(h)  # adds to list
        h1 = vs.FIn3D(h)
        while h1 != []:
            if vs.GetObjectVariableInt(vs.GetLayer(h1), 154) == activetype:
                if vs.GetTypeN(h1) == 15:
                    hSEL.append(h1)  # adds to list
                if vs.GetTypeN(h1) == 86:
                    hSEL.append(h1)  # adds to list
            h1 = vs.NextObj(h1)


def sl_processing(h):  # Omit's Viewports in Sheet Layers
    if vs.GetTypeN(h) != 122:
        assign(h)

hSEL = [] # defines list to contain handles to all selected objects 
activetype = 1
container = 'none'  # Declare container var
ACName = vs.ActiveClass()  # Record name of active class
if vs.GetObject('Construction Phase') == ():  # Creates "Construction Phase" record if not present
    vs.NewField('Construction Phase', 'Phase', '<none>', 4, 0)

if vs.GetObjectVariableInt(vs.ActLayer(), 154) == 2:
    activetype = 2
    vs.ForEachObjectInLayer(sl_processing, 2, 0, 0)
else:
	# Passes Handle to "def pio_processing(h):" of PIO and Symbols selected
	vs.ForEachObject(pio_processing, "((((T=PLUGINOBJECT)|(T=SYMBOL)) & (V) & (SEL=TRUE)))")

	# Passes Handle to "def object_processing(h):" of objects selected except PIO and Symbols outside walls selected
	# Skipped if PIO or Symbol selected was in wall
	if container != 'PIOinwallwasdetected':
		vs.ForEachObject(object_processing, "(((T<>PLUGINOBJECT)&(T<>SYMBOL)&(T<>VIEWPORT) & (V) & (VSEL=TRUE)))")
	for h in hSEL:
		if vs.GetPrefInt(506) != 5:
			if vs.GetLayer(h) == vs.ActLayer():
				assign(h)
		else:
			assign(h)
				
vs.NameClass(ACName)  # Return active class

 

Edited by The Hamma

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.

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.


 

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