Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
DFitting
in reply to: chandra.shekar.g

Thanks for your assistance, the code I've been working on is just about complete. I've figured out a way for a workaround for placing content center parts, I have switched to simply placing them from their respective content center windows explorer folder locations, since iLogic cannot currently place custom item, such as pipes where we can pick various lengths.

 

Basically, what I am wanting for this code, is to place 2 parts from an excel list, and use their named faced, the new 2019 assign name feature, to constrain with an insert constraint that the value varies based off of their sizes. Also, I will need this code to add some custom iproperties to the new assembly before closing it and moving onto the next assembly. The assembly is used in our ASME vessels, and by having a custom iproperites it greatly reduces the amount of time in our drawing creations, mainly the schedule of openings. I just about have the code together, just missing the constraints and the custom iproperties. 

 

Ive attached some sample parts where they have the named faces and an excel file. Ive also attached the entire code that I have been working on. The iproperties assigned are the part number, description and a custom named Service. If I could get some assistance with these last few things, I think that I would be able to finish the code and start creating all these assembly variations. Notice the excel file has 36,937 variations, really its around 210,000 but I changed it to only do the most popular assembly variations, lol, having this code will enable us to create all these, in sections as I doubt my computer could handle all of them at once lol. 

 

SyntaxEditor Code Snippet

Dim path As String
path = "C:\Users\Public\2019\"
NolzPath = "C:\Users\Public\2019\NZLS\"

Dim oList As ArrayList
oList = GoExcel.CellValues(path + "ASSEMBLY GENERATOR.xlsx", "Nozzles", "O2", "O3")
'oList = GoExcel.CellValues(path + "ASSEMBLY GENERATOR.xlsm", "Nozzles", "O2", "O3")

Dim FlangeFolder as String

For Each name In oList
	Dim oNewAssy As AssemblyDocument
	oNewAssy = ThisApplication.Documents.Add(DocumentTypeEnum.kAssemblyDocumentObject)
	


	oNozSize = Split(name, "-")(0)
	'MessageBox.Show(oNozSize, "SIZE")
	oNozSch = Split(name, "-")(1)
	'MessageBox.Show(oNozSch, "SCH")
	oNozLen = Split(name, "-")(2)
	'MessageBox.Show(oNozLen, "LEN")
	oFlgTypeRtng = Split(name, "-")(3)
	'MessageBox.Show(oFlgTypeRtng, "")
	oNozServ = Split(name, "-")(4)
	'MessageBox.Show(oNozServ, "SERVICE")
	
	''remove 1st 5 charachters from file name - ie. NOZLC
	oNozSize = Right(oNozSize, Len(oNozSize) - 5)
	'MessageBox.Show(oNozSize,"size")
	'create values for the rating and type of flange. ie RF150 is RF and 150
	oFlgType = Left(oFlgTypeRtng, Len(oFlgTypeRtng) - 3)
	oFlgRtng = Right(oFlgTypeRtng, Len(oFlgTypeRtng) - 2)
	'MessageBox.Show(oFlgType, "FLNG TYPE")
	'MessageBox.Show(oFlgRtng,"FLNG RATING")

	Try
	oNozSize = (oNozSize).Replace("/", "_")
	Catch
	End Try
	
	Dim oMatrix As Matrix
	oMatrix = ThisApplication.TransientGeometry.CreateMatrix() 
	
	
	FlangePath = "Tube & Pipe:Fittings:Flanges"
	
	If oFlgType = "RF"
	Select Case oFlgRtng
	Case "150"
		FlangeFolder = "ASME B16.5(21)\"
	Case "300"
		FlangeFolder = "ASME B16.5(23)\"
	Case "600"
		FlangeFolder = "ASME B16.5(25)\"
	Case "900"
		FlangeFolder = "ASME B16.5(26)\"
	End Select
	Axis = "False"
	InsertDis = .5
	Else If oFlgType = "WN"
	Select Case oFlgRtng
	Case "150"
		FlangeFolder = "ASME B16.5(38)\"
	Case "300"
		FlangeFolder = "ASME B16.5(41\"
	Case "600"
		FlangeFolder = "ASME B16.5(43)\"
	Case "900"
		FlangeFolder = "ASME B16.5(44)\"
	End Select
	Axis = "True"
	InsertDis = .125
	End If		
	'MessageBox.Show(FlangeFolder, "Title")

	'\\\ here are the paths where the flanges and pipe are saved at. 
	PipePath = "C:\Users\dfitting\Documents\Inventor\Content Center Files\R2019\en-US\ASME B36.10M(1)\" & "PIPEC" & oNozSize & "-" & oNozSch & "-" & oNozLen & ".ipt"
	FlangePath = "C:\Users\dfitting\Documents\Inventor\Content Center Files\R2019\en-US\" & FlangeFolder & "FLNGC" & oNozSize & ".ipt"

	Dim componentA As ComponentOccurrence 
	componentA = oNewAssy.ComponentDefinition.Occurrences.Add(PipePath, oMatrix)
	componentA.Name = "Pipe"

	Dim componentB As ComponentOccurrence 
	componentB = oNewAssy.ComponentDefinition.Occurrences.Add(FlangePath, oMatrix)
	componentB.Name = "Flange"
	

	
	'////////Here is where I need the insert constraint and the iproperties modifications.
'	Dim componentC As ComponentOccurrence
'	componentC = oNewAssy.ComponentDefinition.Occurrences.Add.Constraints("Insert1", "Pipe", "Flange Face", "Flange", "Flange Face",
'                      axesOpposed := Axis, distance := InsertDis, lockRotation := True, biasPoint1 := Nothing, biasPoint2 := Nothing)


'	oNewAssy.ComponentDefinition.Occurrences.Constraints.AddInsert("Insert1", "Pipe", "Flange Face", "Flange", "Flange Face",
'    axesOpposed := Axis, distance := InsertDis, lockRotation := True, biasPoint1 := Nothing, biasPoint2 := Nothing)



	Try
	name = (name).Replace("/", "_")
	Catch
	End Try

	 
	Call oNewAssy.SaveAs(NolzPath + name + ".iam", False)
	
	Call oNewAssy.Close
Next