Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Parent of a child

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
miha_bokan
246 Views, 2 Replies

Parent of a child

Hello there!

I am trying to rename our old files with new naming system. 


The Question:

I was familiar with AllReferencedDocuments function and created, a working loop, where I use:

	Dim oAsmDoc As AssemblyDocument
	oAsmDoc = ThisApplication.ActiveDocument
For Each oRefDoc In oAsmDoc.AllReferencedDocuments


Is there a way to access Parent of Referenced Document?

There is some oRefDoc.Parent option, but I don't know how to use it.

 

I found in all threads, suggestion to use Occurences.... is there another way?

 

The Problem:
Old naming was Project Name P-1112-000, 001, 002 and so on.
The new system has design "XXX.YYYZZZ", where XXX represents if its part, assembly, weldment. It it is weldment, then its subparts do not need drawing, because they are consumed in weldment drawing. With this P-1112-011 weldment subpart becomes 201.YYYZZZ-letter. With "AllReferencedComponents" Loop I know, when I go into assembly, but don't know  when I leave them. My only Info is, that when there is another weldment, I need start using letters from the start. The problem occur, when there were weldment, part1, part2 on same level; and program thought that part1 and part2 were also part of weldment.  

2 REPLIES 2
Message 2 of 3
yuzeaa
in reply to: miha_bokan

Parentdocs = refdoc.ReferencingDocuments

 

Message 3 of 3
miha_bokan
in reply to: yuzeaa

why is iLogic so easy... if you know it 😄

 

The working code:

Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument

Dim oRefDoc As Document

For Each oRefDoc In oAsmDoc.allreferenceddocuments
	If InStr(oRefDoc.DisplayName, "P-") <> 0 Or InStr(oRefDoc.DisplayName, "RP30-") <> 0 Or InStr(oRefDoc.DisplayName, "RVP30-") <> 0 Then
		Logger.Info("Child: " & oRefDoc.DisplayName & "____ Parent: " & oRefDoc.ReferencingDocuments.Item(1).DisplayName)
	End If
Next

*There is additional If sentence, to filter out the unneccesary parts,assemblies... 

Tnx @yuzeaa 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report