ILogic: how to query which environment I am in

ILogic: how to query which environment I am in

SOMAR_engineering
Contributor Contributor
704 Views
3 Replies
Message 1 of 4

ILogic: how to query which environment I am in

SOMAR_engineering
Contributor
Contributor

To all:

 

How, using iLogic, would I determine which enviroment I am in.  For instance, whether I am in the sketch environment, part environment, or assembly environment.

 

Thanks in advance for any help.

0 Likes
Accepted solutions (1)
705 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant

Hi maweilian,


Here is a quick example:

 

Dim oDoc As Document
oDoc = ThisDoc.Document

If oDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject  Then
	If Typeof ThisApplication.ActiveEditObject Is Sketch Then
	MessageBox.Show("You have a sketch active in a part file.", "iLogic")
	Else
	MessageBox.Show("This is a part file.", "iLogic")
	End If
Else If oDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
	If Typeof ThisApplication.ActiveEditObject Is Sketch Then
	MessageBox.Show("You have a sketch active in an assembly file.", "iLogic")
	Else
	MessageBox.Show("This is an assembly file.", "iLogic")
	End If
Else If oDoc.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then
	If Typeof ThisApplication.ActiveEditObject Is Sketch Then
	MessageBox.Show("You have a sketch active in a drawing file.", "iLogic")
	Else
	MessageBox.Show("This is a drawing file.", "iLogic")
	End If
End If

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

EESignature

0 Likes
Message 3 of 4

jdkriek
Advisor
Advisor
Accepted solution

To take it a little further...

 

Select Case ThisDoc.Document.DocumentType
	Case 12289: MSG = "Unknown Document"
	Case 12290: MSG = "Part Document"
	Case 12291: MSG = "Assembly Document"
	Case 12292: MSG = "Drawing Document"
	Case 12293: MSG = "Design Element"
	Case 12294: MSG = "Presentation Document"
	Case 12295: MSG = "Foreign Model"
	Case 12296: MSG = "SAT File"
End Select

If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
	MsgBox(MSG & " with sketch active")
Else
	MsgBox(MSG)
End If
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 4 of 4

Anonymous
Not applicable

Nice concise code!

0 Likes