Created
December 26, 2014 18:10
-
-
Save justinmilo/d85a048cb1ec4ce54270 to your computer and use it in GitHub Desktop.
My base code of shared functions for vectorscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import vs | |
import VSEnums | |
from imp import reload | |
reload (VSEnums) | |
def createClass(newname): | |
# check to see if the class name is in use } | |
if vs.GetObject(newname): | |
# if the class name is not in use, create the class; otherwise alert } | |
# the user and exit the script } | |
vs.NameClass(newname) | |
else: | |
vs.AlrtDialog('Class name already exists.') | |
def printObjects (string, handle): | |
if handle == 0: | |
vs.AlrtDialog("Object is Nill") | |
else: | |
type = vs.GetTypeN(handle) | |
vs.AlrtDialog("The " + string + " is " + str(handle) + " of typeIndex " + str(type) + " of type " + VSEnums.typeOfObject(type)+ " the name is " + str(vs.GetName(handle))) | |
kCreatePullDownMenu = 33 | |
kCreatePullDownMenuGroupBox = 34 | |
kCreateListBox = 29 | |
kCreateListBoxN = 30 | |
kCreatePushButton = 100 | |
#control Type | |
Image = 1 | |
SystemColor = 2 | |
Slider = 3 | |
ImagePopup = 10 | |
GradientSlider = 11 | |
#{Alignment constants} | |
kRight = 1; | |
kBottom = 2; | |
kLeft = 3; | |
kColumn = 4; | |
kResize = 0; | |
kShift = 1; | |
#{ default and cancel button IDs} | |
kOK = 1 | |
kCancel = 2; | |
#{ control IDs} | |
kListBoxText = 4; | |
kListBox1 = 5; | |
kListBrowserText = 6; | |
kListBrowser = 7; | |
kListBox2 = 8; | |
def imageSelectResourceFile (folderID): | |
aListID = 111111 | |
selectINT = 1 | |
objectType = 16 #Symbol Index | |
folderIndex = -2 # Plug-In Data Folder (negative means user folder) | |
aListID, numOfItems = vs.BuildResourceList( objectType , folderIndex, "JRSPlugins/JRSPythonProjectsLinked/VWXSymbols") | |
def dialog2_Handler(item, data): | |
nonlocal selectINT | |
global importedSymbolName | |
kLayoutDialogOpen = 12255 # Documented - Value passed as item when opening | |
kLayoutDialogClosed = 12256 # Documented- Value passed as item when closing | |
kLayoutDialogEndAction = 4 # Think this is after an end action | |
if item == kLayoutDialogOpen: | |
for i in range(0, numOfItems): | |
myInt = vs.InsertImagePopupResource (dialog1, 4, aListID, i) | |
return | |
elif item == kLayoutDialogClosed: | |
hand = vs.ImportResourceToCurrentFile(aListID, selectINT) | |
name = vs.GetName(hand) | |
vs.SetActSymbol(name) | |
elif item == kLayoutDialogEndAction: | |
selectINT = data + 1 | |
else: | |
return | |
dialog1 = vs.CreateLayout('Select From this list', False, 'OK', '') | |
vs.CreateStaticText( dialog1, kListBox1, "My test String", -1 ); | |
vs.CreateThumbnailPopup(dialog1, 4) | |
vs.CreateControl(dialog1, 4, ImagePopup, 'displayName', 0) | |
vs.SetFirstLayoutItem(dialog1, kListBox1) | |
vs.SetBelowItem(dialog1,kListBox1, 4, 0, 0) | |
myInt = vs.RunLayoutDialog(dialog1, dialog2_Handler) | |
def JRSymbol(name, x, y, rotation): | |
if not symbolExists(name): | |
importSymbol(name) | |
vs.Symbol(name, x, y, rotation) | |
return vs.LNewObj() | |
def importSymbol(id): | |
aListID = 1 | |
objectType = 16 #Symbol Index | |
folderIndex = -2 # Plug-In Data Folder (negative means user folder) | |
aListID, numOfItems = vs.BuildResourceList( objectType , folderIndex, "JRSPlugins/JRSPythonProjectsLinked/VWXSymbols") | |
aString = "" | |
for i in range(0, numOfItems): | |
#myInt = vs.InsertImagePopupResource (dialog1, 4, aListID, i) | |
name = vs.GetNameFromResourceList (aListID, i) | |
if name == id: | |
vs.ImportResourceToCurrentFile(aListID, i) | |
def symbolExists (id): | |
objectType = 16 #Symbol Index | |
folderIndex = 0 # Current Document | |
aListID, numOfItems = vs.BuildResourceList( objectType , folderIndex, "") | |
for i in range(0, numOfItems): | |
name = vs.GetNameFromResourceList (aListID, i) | |
if name == id: | |
return True | |
return False | |
def Symbol2D3D(SymString, X, Y, Z, Xr, Yr, Zr): | |
JRSymbol (SymString, X, Y, Xr) | |
vs.Move3DObj(vs.LNewObj(), 0, 0, Z)# to move an individual | |
def Symbol3D(SymString, X, Y, Z, Xr, Yr, Zr): | |
#{ Place a 3D Symbol in the drawing at the specified 3D point and rotations. } | |
JRSymbol (SymString, 0, 0, 0) | |
vs.ResetOrientation3D() | |
vs.SetRot3D (vs.LNewObj(), Xr, Yr, Zr, 0, 0, 0) | |
vs.Move3DObj (vs.LNewObj(), X, Y, Z) | |
# Symbol3D | |
''' Debug Information ''' | |
def stringOfParamaters(): | |
return 'width ' + str(vs.Pwidth) + '. length ' + str(vs.Plength) + '. yaxis ledger ' + str(vs.PyLedgerSize) + '. xaxis ledger ' + str(vs.PxLedgerSize) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment