iLogic Frame gen help!

iLogic Frame gen help!

mtresky
Contributor Contributor
298 Views
3 Replies
Message 1 of 4

iLogic Frame gen help!

mtresky
Contributor
Contributor
Frame Generator IF end treatment exists

Hello,

 

I'm looking to create a rule that searches frame members and determines if the have been modified (miter, notch, etc.) so I can extract that member info and use it for something.

 

If a member has just been cut to a length and is not modified in any other way, it is straight cut of stock. When we miter, notch, modify that part in any way it is no longer just a stock cut and I need to extract that information for company purposes.

 

I have already created a rule to cycle thru everything in the document, extract the individual names, file names, paths, etc. however I cannot find a way to flag end treatments. they are not treated as "features" that can be tested to be active as I thought.

 

I also tried using code to create the "CUTDETAIL1" custom iproperty in the parts (which is populated "out of the box" by frame gen when a treatment is applied) with no luck extracting that data either via code.

 

Any assistance would be great and appreciated, in either calling the end treatments directly or extracting the custom iProperty data for cuts. I have triple checked and the custom iProperty (CUTDETAIL1) for the member DOES exist and holds data (Value = "Miter 45.00 deg") , however my code is not pulling it for some reason.  is value is just blank in my message box everytime, where it is populated everytime i check it manually.

 

My code is below for reference:

 

---

 

Sub Main()

Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
Call Iterate(oAsmDoc.ComponentDefinition.Occurrences, 1)

End Sub

Public Declare Sub Sleep Lib "kernel32"(ByVal dwMilliseconds As Long)

Private Sub Iterate(Occurrences As ComponentOccurrences, Level As Integer)
	'Iterate through Assembly
	Dim oOcc As ComponentOccurrence
	For Each oOcc In Occurrences

		'Find Parts in Assembly
		Dim oNAME As String = oOcc.Name
		Dim oPN As String = iProperties.Value(oNAME, "Project", "Part Number")
		Dim oFILE As Document = oOcc.Definition.Document

		Dim oFNAME As String = oFILE.FullFileName

		'find the postion Of the last backslash In the Path
		FNamePos = InStrRev(oFNAME, "\", -1)
		'get the file name with the file extension
		Name = Right(oFNAME, Len(oFNAME) -FNamePos)
		'get the file name (without extension)
		ShortName = Left(Name, Len(Name) -4)
		'get the path of the folder containing the file
		Folder_Location = Left(oFNAME, Len(oFNAME) -Len(Name))
		
		Dim CUT1 As String
		
		Try
			CUT1 = iProperties.Value(oFILE, "Custom", "CUTDETAIL1")
		Catch
			customPropertySet = oFILE.PropertySets.Item("Inventor User Defined Properties")
			customPropertySet.Add("", "CUTDETAIL1")
			CUT1 = iProperties.Value(oNAME, "Custom", "CUTDETAIL1")

		End Try

		MsgBox("LEVEL: " & Level _
		& vbLf & "DISPLAY: " & oNAME _
		& vbLf & "PN: " & oPN _
		& vbLf & "FULL PATH: " & oFNAME _
		& vbLf & "FILE NAME: " & Name _
		& vbLf & "PART NAME: " & ShortName _
		& vbLf & "FOLDER: " & Folder_Location _
		& vbLf & "CUT: " & CUT1)

		' Check to see if this occurrence represents a subassembly
		' and recursively call this function to traverse through it.
		If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
			Call Iterate(oOcc.SubOccurrences, Level + 1)
		End If

	Next
End Sub


---
0 Likes
299 Views
3 Replies
Replies (3)
Message 2 of 4

cadman777
Advisor
Advisor

You are better off posting this to the Inventor Customization Forum.

Maybe the Mod can move it to there and put a link to it in this thread?

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 3 of 4

A.Acheson
Mentor
Mentor

The ilogic iproperty snippet can be troublesome when not used directly on the document the rule is ran from.

Replace it with the longer API version. Here is a post to access those and how they are displayed. 

 

It looks like you have it semi used in the rule to create the custom iproperty.

Replace

iProperties.Value(oNAME, "Custom", "CUTDETAIL1")

With

customPropertySet.Item("CUTDETAIL1").Value

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 4 of 4

A.Acheson
Mentor
Mentor

I had another look at this and the reason why you were unable to get the custom iproperty is because it is using it's internal name  instead of the display name as an identifier which isn't typical. To determine this you can run the below rule on the open file containing the end treatment. The solution is also discussed here in this post .

 Dim doc As Document
 doc = ThisApplication.ActiveDocument
  
  Dim ps As PropertySet
  For Each ps In doc.PropertySets
   Logger.Info( ps.Name + " / " + ps.InternalName)

    Dim p As [Property]
    For Each p In ps
      Logger.Info( "  " + p.Name + " /" + Str(p.PropId))
    Next
  Next
  

 

AAcheson_0-1651949575554.png

Here is the working rule. Indicated are three methods to get the iProperty value. You can use which ever is easier. The API help file has a detailed example of working with property sets. Simply search the key words property sets and you will find the details.

Sub Main()

Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
Call Iterate(oAsmDoc.ComponentDefinition.Occurrences, 1)

End Sub

Public Declare Sub Sleep Lib "kernel32"(ByVal dwMilliseconds As Long)

Private Sub Iterate(Occurrences As ComponentOccurrences, Level As Integer)
	'Iterate through Assembly
	Dim oOcc As ComponentOccurrence
	For Each oOcc In Occurrences
		'Find Parts in Assembly
		Dim oNAME As String = oOcc.Name

		Dim oFILE As Document = oOcc.Definition.Document
		Dim oPN As String =  oFILE.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
		Dim oFNAME As String = oFILE.FullFileName

		'find the postion Of the last backslash In the Path
		FNamePos = InStrRev(oFNAME, "\", -1)
		'get the file name with the file extension
		Name = Right(oFNAME, Len(oFNAME) -FNamePos)
		'get the file name (without extension)
		ShortName = Left(Name, Len(Name) -4)
		'get the path of the folder containing the file
		Folder_Location = Left(oFNAME, Len(oFNAME) -Len(Name))
		
		Dim CUT1 As String
		
		Try
			customPropertySet = oFILE.PropertySets.Item("Inventor User Defined Properties")
			'Method1: Loop through custom iProperties and detect properties by there display name
			For Each sProperty As [Property] In customPropertySet
				If sProperty.DisplayName = "CUTDETAIL1" Then
					CUT1 = sProperty.Value
				End If	
			Next

			'Method2: Item By Property Id
			'CUT1 = customPropertySet.ItemByPropId(9).Value
			'Method3:Item By Internal Name
			'CUT1 = customPropertySet.Item("AE45F7BA-ACF1-4E92-9E22-549D8180C4AF").Value 
		Catch
			MessageBox.Show("Error", "Title")
		End Try

		MsgBox("LEVEL: " & Level _
		& vbLf & "DISPLAY: " & oNAME _
		& vbLf & "PN: " & oPN _
		& vbLf & "FULL PATH: " & oFNAME _
		& vbLf & "FILE NAME: " & Name _
		& vbLf & "PART NAME: " & ShortName _
		& vbLf & "FOLDER: " & Folder_Location _
		& vbLf & "CUT: " & CUT1)

		' Check to see if this occurrence represents a subassembly
		' and recursively call this function to traverse through it.
		If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
			Call Iterate(oOcc.SubOccurrences, Level + 1)
		End If

	Next
End Sub

  

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes