# coding: utf-8
#
# Copyright © 2020 MSC.Software Corporation
#  
# Permission to use Scripts
#  
# Permission is granted to MSC.Software customers with valid licenses of the MSC Apex™ software 
# to use script files posted on this page (collectively “Scripts”) solely for customers’ own authorized 
# internal use in conjunction with licensed use of the MSC Apex software.  
# No other use is permitted.  No license to MSC Apex or other software is granted under this Permission.
#  
# SCRIPTS ARE PROVIDED ON AN "AS-IS" BASIS, WITH NO WARRANTIES OF ANY KIND.  USE OF THE SCRIPTS IS AT CUSTOMER'S SOLE RISK.
#  
# IN NO EVENT SHALL MSC.SOFTWARE CORPORATION, ITS AFFILIATES, SUBSIDIARIES, SUPPLIERS, AGENTS, REPRESENTATIVES OR EMPLOYEES BE LIABLE FOR ANY 
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, 
# STRICT LIABILITY, OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION USE OF THE SCRIPTS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
#  
# Customer shall indemnify, defend and hold MSC.Software Corporation, its affiliates, subsidiaries, suppliers, agents, 
# employees or representatives (collectively, “Indemnified Parties”) harmless from and against any third-party claims 
# brought against Indemnified Parties rising out of or in connection with Customer’s use of the Scripts.
#
# Macro created by MSC Apex MSC_Apex Harris Hawk SP2 PRE - Version CLR:598656
# Macro created on Oct 09, 2018 at 11:15:14
# 
# Macro Name = auf_batch_modules_IL_v03
# 
# Macro Description = tool modules for batch processing (Iberian Lynx FP1)
# 
# Macro Hot Key = Ctrl+A
# 
# Initialize Apex environment for macro execution
# 

import apex
from apex.construct import Point3D, Point2D

from get_stuff_3 import *


if 1==1:
	# move bolt parts to TempPart
	model_1 = apex.currentModel()

	solids = getAllSolids()
	tmp_solids = apex.entityCollection()
	_target = apex.entityCollection()

	# #Create tmp_part if not existing
	# try:
		# tmp_part = model_1.getPart( name = "Temp_repository" )
	# except:
		# tmp_part = model_1.createPart()
		# updatedPartName_ = tmp_part.update( name = "Temp_repository" )


	for solid in solids:
		try:
			tmp_attributes=solid.getUserAttributes(['ParentPart'])
			parent_part_name=tmp_attributes[0].getStringValue()
			_target.append(solid)
		except:
			continue
	
	try:
		#parent_part = model_1.getPart( name = parent_part_name )			
		#apex.reparent( parent = tmp_part, target = _target )
		apex.deleteEntities(short_edges)
	except:
		print("parent Part: " + parent_part_name + " could not be found")
	
	# hide temporary part
	#tmp_part.hide()
else:
	print("Do nothing")
