from abaqus import *
from abaqusConstants import *
from caeModules import *
from odbAccess import *
import math, os, os.path, string, csv
import numpy as np
from part import *
from material import *
from section import *
from assembly import *
from step import *
from interaction import *
from load import *
from mesh import *
from optimization import *
from job import *
from sketch import *
from visualization import *
from connectorBehavior import *
import sys
sys.path.insert(34,
r'c:/Program Files/Simulia/Abaqus/6.14-3/code/python2.7/lib/abaqus_plugins/findNearestNode')
import nearestNodeModule
m2=mdb.models['Model-2']
p2=m2.parts['Full_Model_1']
a2=m2.rootAssembly
sgx=[5486.4,5486.4,5486.4,5486.4,5486.4,5486.4,5486.4,5486.4,5232.4,5232.4,5232.4,5232.4,5232.4,5232.4,4569.02185,4569.02185,4568.99645,4568.99772,4568.98375,4568.98375,4419.6,4419.6,4419.6,4483.1,4483.1,4483.1,4483.1,4483.1,4483.1,4483.1,4483.1,4267.2,4267.2,4267.2,3962.4,3962.4,3962.4,3657.6,3657.6,3657.6,3657.6,3657.6,3657.6,3657.6,3657.6,1828.8,1828.8,1828.8,1828.8,1828.8,1828.8,1828.8,1828.8]
sgy=[2133.6,2133.6,1524,1524,914.4,914.4,304.8,304.8,1828.8,1828.8,1219.2,1219.2,609.6,609.6,2133.6,2133.6,1524,1524,304.8,304.8,2133.6,1524,304.8,2130.7806,2136.4194,2130.7806,2136.4194,1521.4219,1526.5781,1521.4219,1526.5781,2133.6,1524,304.8,2133.6,1524,304.8,2133.6,2133.6,1524,1524,914.4,914.4,304.8,304.8,2133.6,2133.6,1524,1524,914.4,914.4,304.8,304.8]
sgz=[125.5014,1.5875,127.1143,1.5875,305.816,1.5875,123.6345,1.5875,8.0391,1.5875,7.7851,1.5875,7.9883,1.5875,125.4887,1.5875,125.73,1.5875,121.9581,1.5875,125.4887,125.73,121.9581,90.17,90.17,8.4963,8.4963,90.17,90.17,8.2677,8.2677,1.5875,1.5875,1.5875,1.5875,1.5875,1.5875,123.9012,0,124.1425,0,303.9999,0,120.3706,0,123.7869,0,125.5903,0,304.165,0,123.5456,0]
#NodeSG={}
session.viewports['Viewport: 1'].setValues(displayedObject=a2)
for i in range(1,53+1):
sg=nearestNodeModule.findNearestNode(xcoord=sgx[i-1], ycoord=sgy[i-1], zcoord=sgz[i-1], name='')
NodeSG[i-1]=sg[0]
sGgNodei = NodeSG[i-1]
setSg = 'sGg'+str(i)
p2.Set(name=setSg, nodes=p2.nodes[sGgNodei-1:sGgNodei])
m2.rootAssembly.regenerate()