Open a file from Assembly with iLogic

Open a file from Assembly with iLogic

Anonymous
Not applicable
1,513 Views
5 Replies
Message 1 of 6

Open a file from Assembly with iLogic

Anonymous
Not applicable

Hi,

 

is there a iLogic rule to open a part froma the assembly browser?

I tried this code but it doesent work 😞

 

compo = Component.InventorComponent("Obere Rahmen:1")
compo.Open

0 Likes
Accepted solutions (2)
1,514 Views
5 Replies
Replies (5)
Message 2 of 6

MechMachineMan
Advisor
Advisor
Try delving deeper into the API Help, and going through some examples rather than posting 10 million times on the forums trying to get other people to do your work for you.

Also, the "SEARCH THIS BOARD" feature is superb. I suggest you give it a try.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 6

nbarbars
Enthusiast
Enthusiast

So helpful... Maybe you're doing the small amount of work for them (if you know API and iLogic, this would take you less than 5 minutes), but you're helping countless people years later dealing with the same issue. These few lines you could've posted would have been great help to further learn this coding, as most of us will learn by trial and error.

0 Likes
Message 4 of 6

MechMachineMan
Advisor
Advisor
Accepted solution

1. Do you think I was magically born with all of this knowledge, or did I perhaps go through the same struggles of trial and error with this?

 

2. You're not entitled to anyone's help. Maybe reconsider your perspective. Would helping people be the "nice" thing to do? Yes. Is helping people a requirement/owed to people? No.

 

3. Read and learn. It's a sloppy mix of iLogic and vb.net, but it works.

Sub Main()
	OpenDocByBrowserName("PartB:1")
End Sub

Sub OpenDocByBrowserName(oBrowserName)
	Dim compOcc As Inventor.ComponentOccurrence
	Try
		compOcc = Component.InventorComponent(oBrowserName)
	Catch
		MsgBox("Issue finding browser name." & vbLf & vbLf & Chr(34) & oBrowserName & Chr(34))
		Exit Sub
	End Try
	
	Dim oDoc As Inventor.Document
	oDoc = compOcc.Definition.Document
	oDocName = oDoc.FullDocumentName
	
	Try
		ThisApplication.Documents.Open(oDocName, True)
	Catch
		MsgBox("File has not been saved or other issue opening file occurred" & vbLf & vbLf & Chr(34) & oBrowserName & Chr(34))
		Exit Sub
	End Try
End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 5 of 6

nbarbars
Enthusiast
Enthusiast

These few lines you posted has been great help to further learn this coding, as I mostly learn by trial and error. Thank you.

Message 6 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi everyone,

 

here is another example for doing this, that I use... 

 

oOcc = "PartA:1"

Try 
	ThisDoc.Launch(Component.InventorComponent(oOcc).Definition.Document.FullFileName)
Catch
End Try

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
 

EESignature