Need help searching for only accessible parts / don't know why my for loop is counting things all parts in a sub assembly when I want to count the accessible ones

Need help searching for only accessible parts / don't know why my for loop is counting things all parts in a sub assembly when I want to count the accessible ones

Preston_Reed
Advocate Advocate
755 Views
7 Replies
Message 1 of 8

Need help searching for only accessible parts / don't know why my for loop is counting things all parts in a sub assembly when I want to count the accessible ones

Preston_Reed
Advocate
Advocate

Ok so I'm writing some code to search through all the sub assemblies, checking to see if the piece parts have a specific custom iprop & then using that in order to apply a numbering system.  This would be done at the end of the project and certain parts go in the 001-099, some in 100-199 & 200-299 and so on.  Any ways, the current way im trying to do it is with the first loop which counts how many parts have this custom iprop (NOT WORKING), then the second loop apply the part numbers. 

 

 

Sub iPropPiecePartNumbers
	Dim TextStrng As String
	Dim Result() As String
	Dim PSnumber As String
		'String array to string
		TextStrng = iProperties.Value("Project", "Project")
		Result = Split(TextStrng, "-")
		PSnumber = Result(2) 
		
	Dim SkidCount As String = "000"
	Dim ManifoldCount As String = "100"
	Dim DSRCount As String = "200"
	Dim PipespoolCount As String = "300"
	Dim FlushlineCount As String = "400"
	
	Dim i As Integer = 0
	Dim j As Integer = 0
	Dim h As Integer = 0
	Dim g As Integer = 0
	Dim f As Integer = 0
	
	Dim count1 As Integer 
	Dim count2 As Integer 
	Dim count3 As Integer 
	Dim count4 As Integer 
	Dim count5 As Integer 
	
	Dim oAsmCompDef As AssemblyComponentDefinition
	oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
	'Iterate through all Of the occurrences
	Dim oOccurrence As ComponentOccurrence

		
	For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)  	
		'Searching through the top level assembly file in order to locate only part files
		If oOccurrence.DefinitionDocumentType = kPartDocumentObject Then 
			comp = Component.InventorComponent(oOccurrence.Name)
			Dim doc = comp.Definition.Document
			On Error Resume Next 
			Dim propset = doc.PropertySets("Inventor User Defined Properties").Item("S0Class").Value
			Dim prop As String = CStr(propset)
			Dim newname As String
Trace.WriteLine("iLogic: iPropPiecePartNumbers | oOccurrence.Name: " & oOccurrence.Name)			
				If prop = "SKID" Then 
					i = 1 + i
Trace.WriteLine("iLogic: iPropPiecePartNumbers | i: " & i)					
				ElseIf prop = "MANIFOLD" Then
					j = 1 + j
Trace.WriteLine("iLogic: iPropPiecePartNumbers | j: " & j)					
				ElseIf prop = "DSR" Then
					h = 1 + h
Trace.WriteLine("iLogic: iPropPiecePartNumbers | h: " & h)					
				ElseIf prop = "PIPE SPOOL" Then
					g = 1 + g
Trace.WriteLine("iLogic: iPropPiecePartNumbers | g: " & g)					
				ElseIf prop = "FLUSHLINE" Then
					f = 1 + f
Trace.WriteLine("iLogic: iPropPiecePartNumbers | f: " & f)					
				End If
		Else
		End If 
	Next
Trace.WriteLine("iLogic: iPropPiecePartNumbers | i total: " & i)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | j total: " & j)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | h total: " & h)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | g total: " & g)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | f total: " & f)

	For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)  	
		'Searching through the top level assembly file in order to locate only part files
		If oOccurrence.DefinitionDocumentType = kPartDocumentObject Then 
			comp = Component.InventorComponent(oOccurrence.Name)
			Dim doc = comp.Definition.Document
			On Error Resume Next 
			Dim propset = doc.PropertySets("Inventor User Defined Properties").Item("S0Class").Value
			Dim prop As String = CStr(propset)
			Dim newname As String
				If prop = "SKID" Then 
					For count1 = 1 To i 
						SkidCount = _
						(Convert.ToInt32(New String(SkidCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + SkidCount
						
						iProperties.Value(oOccurrence.Name, "Project", "Part Number") = newname
						'write to component iprops
						On Error Resume Next
						iProperties.Value(oOccurrence.Name, "Project", "Part Number") = _
						iProperties.Value(oOccurrence.Name, "Project", "Part Number")	
					Next
				ElseIf prop = "MANIFOLD" Then
					For count2 = 1 To j
						ManifoldCount = _
						(Convert.ToInt32(New String(ManifoldCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + ManifolfCount
						
						iProperties.Value(oOccurrence.Name, "Project", "Part Number") = newname
						'write to component iprops
						On Error Resume Next
						iProperties.Value(oOccurrence.Name, "Project", "Part Number") = _
						iProperties.Value(oOccurrence.Name, "Project", "Part Number")	
					Next
				ElseIf prop = "DSR" Then
					For count3 = 1 To h
						DSRCount = _
						(Convert.ToInt32(New String(DSRCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + DSRCount
						
						iProperties.Value(oOccurrence.Name, "Project", "Part Number") = newname
						'write to component iprops
						On Error Resume Next
						iProperties.Value(oOccurrence.Name, "Project", "Part Number") = _
						iProperties.Value(oOccurrence.Name, "Project", "Part Number")	
					Next
				ElseIf prop = "FLUSHLINE" Then
					For count4 = 1 To g
						PipespoolCount = _
						(Convert.ToInt32(New String(PipespoolCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + PipespoolCount
						
						iProperties.Value(oOccurrence.Name, "Project", "Part Number") = newname
						'write to component iprops
						On Error Resume Next
						iProperties.Value(oOccurrence.Name, "Project", "Part Number") = _
						iProperties.Value(oOccurrence.Name, "Project", "Part Number")	
					Next
				ElseIf prop = "PIPE SPOOL" Then
					For count5 = 1 To f
						FlushlineCount = _
						(Convert.ToInt32(New String(FlushlineCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + FlushlineCount
						
						iProperties.Value(oOccurrence.Name, "Project", "Part Number") = newname
						'write to component iprops
						On Error Resume Next
						iProperties.Value(oOccurrence.Name, "Project", "Part Number") = _
						iProperties.Value(oOccurrence.Name, "Project", "Part Number")	
					Next
				End If
									
		Else
		End If 
	Next
End Sub

 

Preston_Reed_0-1692055756209.png

Preston_Reed_2-1692055889358.png

Final count for i = 4 should be 1

final count for j = 8 should be 2

and so on

 

i for example, i should only have access to the -300 part, the other two are in a purchase drive, can not write to them & i dont want to count them anyways. 

Preston_Reed_1-1692055861885.png

 

Any help is appreciated 

0 Likes
Accepted solutions (1)
756 Views
7 Replies
Replies (7)
Message 2 of 8

A.Acheson
Mentor
Mentor

Hi @Preston_Reed 

 

If you want to avoid read only files then you can use PartDocument.IsModifiable() As Boolean. See help file here

 

Also if you don't need to count the occurrences then using reference document will be more efficient as your only working with the first occurrence of each part. I haven't seen any use of the count function other than for your own reference but maybe you have another reason to use the occurrence method. 

 

 ' Get the active assembly.
    Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
    ' Get all of the referenced documents.
    Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments

    ' Iterate through the list of documents.
    For Each oRefDoc As Document  In oRefDocs
        Trace.WriteLine("iLogic:" & oRefDoc.DisplayName)
    Next

 

 

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

Preston_Reed
Advocate
Advocate

@A.Acheson ok i see what your saying about just grabbing the reference doc, i made some changes.  Im still confused with how its actually applying numbers.  For example, under the DSR section, its a single sub assembly, with 2 modifiable parts and 2 non modifiable parts.  When i count in the first loop I come up with a sum h = 3.  It really should be h=2 but i didnt add any checks for kPartDocumentObject so its counting the sub assembly as the 3rd.  

 

When it goes to apply the new part number in the second loop it starts at "204" and then the next part is "208".  I am trying to get "200", "201".  Same deal with the other sections too, want "001", "002", "003" / "100", "101", "102" / "300", "301", "302"

 

if i need to skip 100, 200, 300 in order to start each section at 101, 201, 301 in order to replicate 001 thats fine. 

 

 

#Region "iPropPiecePartNumbers"
	
Sub iPropPiecePartNumbers
	Dim TextStrng As String
	Dim Result() As String
	Dim PSnumber As String
		'String array to string
		TextStrng = iProperties.Value("Project", "Project")
		Result = Split(TextStrng, "-")
		PSnumber = Result(2) 
		
	Dim SkidCount As String = "000"
	Dim ManifoldCount As String = "100"
	Dim DSRCount As String = "200"
	Dim PipespoolCount As String = "300"
	Dim FlushlineCount As String = "400"
	
	Dim i As Integer = 0
	Dim j As Integer = 0
	Dim h As Integer = 0
	Dim g As Integer = 0
	Dim f As Integer = 0
	
	Dim count1 As Integer 
	Dim count2 As Integer 
	Dim count3 As Integer 
	Dim count4 As Integer 
	Dim count5 As Integer 
	
	 ' Get the active assembly.
    Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
    ' Get all of the referenced documents.
    Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments

    ' Iterate through the list of documents.
    For Each oRefDoc As Document  In oRefDocs
		If oRefDoc.IsModifiable() = False  
				GoTo NextIteration
		End If
			On Error Resume Next
		Dim propset = oRefDoc.PropertySets("Inventor User Defined Properties").Item("S0Class").Value
		Dim prop As String = CStr(propset)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | oRefDoc: " & oRefDoc.FullFileName)		
			If prop = "SKID" Then 
				i = 1 + i
Trace.WriteLine("iLogic: iPropPiecePartNumbers | i: " & i)					
			ElseIf prop = "MANIFOLD" Then
				j = 1 + j
Trace.WriteLine("iLogic: iPropPiecePartNumbers | j: " & j)	
			ElseIf prop = "DSR" Then
				h = 1 + h
Trace.WriteLine("iLogic: iPropPiecePartNumbers | h: " & h)	
			ElseIf prop = "PIPE SPOOL" Then
				g = 1 + g
Trace.WriteLine("iLogic: iPropPiecePartNumbers | g: " & g)	
			ElseIf prop = "FLUSHLINE" Then
				f = 1 + f
Trace.WriteLine("iLogic: iPropPiecePartNumbers | f: " & f)	
			End If
		NextIteration:
    Next

Trace.WriteLine("iLogic: iPropPiecePartNumbers | i total: " & i)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | j total: " & j)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | h total: " & h)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | g total: " & g)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | f total: " & f)
	
	For Each oRefDoc As Document  In oRefDocs
			If oRefDoc.IsModifiable() = False 
					GoTo NextIteration2
			End If
		Dim propset = oRefDoc.PropertySets("Inventor User Defined Properties").Item("S0Class").Value
		Dim prop As String = CStr(propset)
		Dim newname As String
			If prop = "SKID" Then 
				For count1 = 1 To i 
						SkidCount = _
						(Convert.ToInt32(New String(SkidCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + SkidCount
						
						iProperties.Value(oRefDoc.Name, "Project", "Part Number") = newname
						'write to component iprops
						On Error Resume Next
						iProperties.Value(oRefDoc.Name, "Project", "Part Number") = _
						iProperties.Value(oRefDoc.Name, "Project", "Part Number")	
					Next
			ElseIf prop = "MANIFOLD" Then
				For count2 = 1 To j
						ManifoldCount = _
						(Convert.ToInt32(New String(ManifoldCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + ManifolfCount
						
						iProperties.Value(oRefDoc.Name, "Project", "Part Number") = newname
						'write to component iprops
						On Error Resume Next
						iProperties.Value(oRefDoc.Name, "Project", "Part Number") = _
						iProperties.Value(oRefDoc.Name, "Project", "Part Number")	
					Next
			ElseIf prop = "DSR" Then
				For count3 = 1 To h
						DSRCount = _
						(Convert.ToInt32(New String(DSRCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + DSRCount
						
						iProperties.Value(oRefDoc.Name, "Project", "Part Number") = newname
						'write to component iprops
						On Error Resume Next
						iProperties.Value(oRefDoc.Name, "Project", "Part Number") = _
						iProperties.Value(oRefDoc.Name, "Project", "Part Number")	
					Next
			ElseIf prop = "PIPE SPOOL" Then
				For count4 = 1 To g
						PipespoolCount = _
						(Convert.ToInt32(New String(PipespoolCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + PipespoolCount
						
						iProperties.Value(oRefDoc.Name, "Project", "Part Number") = newname
						'write to component iprops
						On Error Resume Next
						iProperties.Value(oRefDoc.Name, "Project", "Part Number") = _
						iProperties.Value(oRefDoc.Name, "Project", "Part Number")	
					Next
			ElseIf prop = "FLUSHLINE" Then
				For count5 = 1 To f
						FlushlineCount = _
						(Convert.ToInt32(New String(FlushlineCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + FlushlineCount
						
						iProperties.Value(oRefDoc.Name, "Project", "Part Number") = newname
						'write to component iprops
						On Error Resume Next
						iProperties.Value(oRefDoc.Name, "Project", "Part Number") = _
						iProperties.Value(oRefDoc.Name, "Project", "Part Number")	
					Next
			End If
		NextIteration2:
    Next
End Sub

#End Region

 

0 Likes
Message 4 of 8

Preston_Reed
Advocate
Advocate

Ok i cleaned it up quiet a bit more.  I still have a problem though, I'm including multiple occurrences so numbering still is off.  Not sure if there is a way to disregard them or if i should restructure how I'm doing this.  

 

 

#Region "iPropPiecePartNumbers"
	
Sub iPropPiecePartNumbers
	'Capture 0000XXX number for project number
	Dim TextStrng As String
	Dim Result() As String
	Dim PSnumber As String
		'String array to string
		TextStrng = iProperties.Value("Project", "Project")
		Result = Split(TextStrng, "-")
		PSnumber = Result(2) 
	
	'Declaring the starting point string for each part category
	Dim SkidCount As String = "000"
	Dim ManifoldCount As String = "100"
	Dim DSRCount As String = "200"
	Dim PipespoolCount As String = "300"
	Dim FlushlineCount As String = "400"
	
	'Setting integers in order to count how many of each part are in each category
	Dim i As Integer = 0
	Dim j As Integer = 0
	Dim h As Integer = 0
	Dim g As Integer = 0
	Dim f As Integer = 0
	
	 ' Get the active assembly.
    Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
    ' Get all of the referenced documents.
    Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments

    ' Iterate through the list of documents.
    For Each oRefDoc As Document In oRefDocs
		'Skipping any purchased or mfg parts / any parts that are not accessable 
		If oRefDoc.IsModifiable() = False  
				GoTo NextIteration
		End If
			On Error Resume Next
		'Checking to see if the part files have custom iProp "S0Class" declared 
		Dim propset = oRefDoc.PropertySets("Inventor User Defined Properties").Item("S0Class").Value
		Dim prop As String = CStr(propset)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | oRefDoc: " & oRefDoc.FullFileName)		
			If prop = "SKID" Then 
				i = 1 + i
Trace.WriteLine("iLogic: iPropPiecePartNumbers | i: " & i)					
			ElseIf prop = "MANIFOLD" Then
				j = 1 + j
Trace.WriteLine("iLogic: iPropPiecePartNumbers | j: " & j)	
			ElseIf prop = "DSR" Then
				h = 1 + h
Trace.WriteLine("iLogic: iPropPiecePartNumbers | h: " & h)	
			ElseIf prop = "PIPE SPOOL" Then
				g = 1 + g
Trace.WriteLine("iLogic: iPropPiecePartNumbers | g: " & g)	
			ElseIf prop = "FLUSHLINE" Then
				f = 1 + f
Trace.WriteLine("iLogic: iPropPiecePartNumbers | f: " & f)	
			End If
		NextIteration:
    Next

Trace.WriteLine("iLogic: iPropPiecePartNumbers | i total: " & i)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | j total: " & j)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | h total: " & h)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | g total: " & g)
Trace.WriteLine("iLogic: iPropPiecePartNumbers | f total: " & f)
		
	  ' Iterate through the list of documents.
    For Each oRefDoc As Document In oRefDocs
		'Skipping any purchased or mfg parts / any parts that are not accessable 
		If oRefDoc.IsModifiable() = False  
				GoTo NextIteration2
		End If
			On Error Resume Next
			
		' Get the PropertySets object.
	    Dim oPropSets As PropertySets
	    oPropSets = oRefDoc.PropertySets
	    ' Get the design tracking property set.
	    Dim oPropSet As PropertySet
	    oPropSet = oPropSets.Item("Design Tracking Properties")
	    ' Get the part number iProperty.
	    Dim oPartNumiProp As [Property] 
	    oPartNumiProp = oPropSet.Item("Part Number")	
		
		Dim propset = oRefDoc.PropertySets("Inventor User Defined Properties").Item("S0Class").Value
		Dim prop As String = CStr(propset)
		
			If prop = "SKID" Then 
				SkidCount = _
						(Convert.ToInt32(New String(SkidCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + SkidCount
Trace.WriteLine("iLogic: iPropPiecePartNumbers | SKID: " & SkidCount)
						oPartNumiProp = newname	
Trace.WriteLine("iLogic: iPropPiecePartNumbers | SKID: " & newname)
			ElseIf prop = "MANIFOLD" Then
				ManifoldCount = _
						(Convert.ToInt32(New String(ManifoldCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + ManifoldCount
Trace.WriteLine("iLogic: iPropPiecePartNumbers | MANIFOLD: " & ManifoldCount)
						oPartNumiProp = newname	
Trace.WriteLine("iLogic: iPropPiecePartNumbers | MANIFOLD: " & newname)
			ElseIf prop = "DSR" Then
				DSRCount = _
						(Convert.ToInt32(New String(DSRCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + DSRCount
Trace.WriteLine("iLogic: iPropPiecePartNumbers | DSRCount: " & DSRCount)
						oPartNumiProp = newname	
Trace.WriteLine("iLogic: iPropPiecePartNumbers | DSR: " & newname)						
			ElseIf prop = "FLUSHLINE" Then
				FlushlineCount = _
						(Convert.ToInt32(New String(FlushlineCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + FlushlineCount
Trace.WriteLine("iLogic: iPropPiecePartNumbers | FLUSHLINE: " & FlushlineCount)						
						oPartNumiProp = newname	
Trace.WriteLine("iLogic: iPropPiecePartNumbers | FLUSHLINE: " & newname)
			ElseIf prop = "PIPE SPOOL" Then
				PipespoolCount = _
						(Convert.ToInt32(New String(PipespoolCount)) + 1).ToString("D3")
						newname = "PS-" + PSnumber + "-" + PipespoolCount
Trace.WriteLine("iLogic: iPropPiecePartNumbers | PIPE SPOOL: " & PipespoolCount)						
						oPartNumiProp = newname	
Trace.WriteLine("iLogic: iPropPiecePartNumbers | PIPE SPOOL: " & newname)
			End If		
			
			'write to component iprops
			On Error Resume Next
			oPartNumiProp = _
			oPartNumiProp
		
		NextIteration2:
	Next 
				
	
End Sub

#End Region

 

0 Likes
Message 5 of 8

A.Acheson
Mentor
Mentor

Hi @Preston_Reed 

 

Glad to see you making progress. So if I understand correctly you just want to create a new partnumber based on the category each part falls under.

I think an easier method to not physically count the occurrences but to count the parts on a per category basis. So create a list of string for each category and loop through the part documents checking the category if it matches then add the partnumber and the list of string count. This way you can use just one loop.  The below is untested so could have errors but hopefully it will give you another shorter method to do what you need. 

 

Edit is Modifiable should be true not false to avoid read only files. 

 

 

#Region "iPropPiecePartNumbers"
	
Sub iPropPiecePartNumbers
	'Capture 0000XXX number for project number
	Dim TextStrng As String
	Dim Result() As String
	Dim PSnumber As String
        'String array to string
        TextStrng = iProperties.Value("Project", "Project")
        Result = Split(TextStrng, "-")
	PSnumber = Result(2) 
	
	'Declaring the starting point string for each part category
       Dim SkidNoStart As String = "000"
       Dim ManifoldNoStart As String = "100"
       Dim DSRCountNoStart As String = "200"
       Dim PipespoolNoStart As String = "300"
       Dim FlushlineNoStart As String = "400"
       Dim SkidQty as New List (Of String)
       Dim ManifoldQty as New List (Of String)
       Dim DSRCountQty as New List (Of String)
       Dim PipespoolQty as New List (Of String)
       Dim FlushlineQty as New List (Of String)
		
	 ' Get the active assembly.
    Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
    ' Get all of the referenced documents.
    Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments

    ' Iterate through the list of documents.
    For Each oRefDoc As Document In oRefDocs
		'Skipping any purchased or mfg parts / any parts that are not accessable 
		If oRefDoc.IsModifiable() = False AndAlso RefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then	
		'Checking to see if the part files have custom iProp "S0Class" declared 
		Dim propset = oRefDoc.PropertySets("Inventor User Defined Properties").Item("S0Class").Value
		Dim prop As String = CStr(propset)
         Trace.WriteLine("iLogic: iPropPiecePartNumbers | oRefDoc: " & oRefDoc.FullFileName)		
	   If prop = "SKID" Then 
				 
                SkidQty.Add(SkidNoStart + SkidQty.Count
          End If
    Next

 

 

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

Preston_Reed
Advocate
Advocate

Hey @A.Acheson , I've been messing with this over the past few days and I understand what your doing and I've messed with the code and the majority of it seems to be working well.  When I trace the values its counting properly.  However I cant seem to figure out how to apply the new part number values to the parts.  I know how to do it using occurrences but cant seem to figure it out with Document.  How do i apply the new value via oRefDoc?  

0 Likes
Message 7 of 8

A.Acheson
Mentor
Mentor
Accepted solution

Use the API Property Method like this. In fact when you do it with occurrences, where you are actually getting to the document from the occurrence definition so this is more direct. 

	' Get the PropertySets object.
	    Dim oPropSets As PropertySets = oRefDoc.PropertySets
	    ' Get the design tracking property set.
	    Dim oPropSet As PropertySet = oPropSets.Item("Design Tracking Properties")
	    ' Get the part number iProperty.
	    Dim oPartNumiProp As [Property] = oPropSet.Item("Part Number")
oPartNumiProp.Value = "......."

 

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

Preston_Reed
Advocate
Advocate

@A.Acheson thats amazing, works perfectly, thank you so much 

0 Likes