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: 

Set open document as the active target

1 REPLY 1
SOLVED
Reply
Message 1 of 2
josh.linares-stanley
128 Views, 1 Reply

Set open document as the active target

This is part of a larger code:

 

The purpose is to open a referenced drawing file to an attempt to retrieve the "revision value iproperty" from the IDW. For the most part it works except it uses the revision value of the original assembly/part file, not the drawing it that is opened.

 

My initial instinct was that after the IDW file was opened, I'd need to somehow set that as the active document...

 

Dim doc As Document = ThisDoc.Document
Dim docType As String = ""

If
docType = "Part" Or docType = "Assembly" Then 'ask whether to retrive revsion from linked drawing or manually input the revision Booleanparam = InputRadioBox("How do you wish to extract part revision?", "Open Drawing", "Manual Input", booleanParam, Title := "Revision input") 'open drawing document referenced to file If Booleanparam = True Then Try oDWG = ThisDoc.FileName(False) & ".idw" OpenDoc = ThisDoc.Launch(oDWG) RevDigit = iProperties.Value("Project", "Revision Number") Catch MessageBox.Show("No Drawing Found", "") End Try 'Manually Input revision Else If Booleanparam = False Then 'choose revision digit Dim Result, Message, Title, DefaultValue As String Message = "Enter revision digit" Title = "Input Box" DefaultValue = "0" RevDigit = InputBox(Message, Title, DefaultValue) End If

 

Tags (2)
1 REPLY 1
Message 2 of 2

Hi @josh.linares-stanley 

Because your launching documents and attempting to read iproperties I would avoid the ilogic API and move to the inventor API and properties. 

 

Ilogic API generally work to target documents that the rule is first run in which in this case is a part or assembly.

While you can target a document it is difficult. 

 

Here is the Inventor API set up for part number..

 

' Get the active document.
Dim drawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim designPropSet As PropertySet = drawDoc.PropertySets.Item("Design Tracking Properties")

Dim partNo as String = designPropSet.Item("Part Number").Value

MessageBox.Show(partNo,"iLogic")

 

 In your case you need to change the above sample as you want to target revision number which is in Property Set " Inventor Summary Information" and Property "Revision Number".

Here is a helpful article which lays out all of this method. It is written in VBA so ensure you drop the word Set for use in ilogic environment.

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

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report