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: 

INSERT SKETCHED SYMBOL IF PART IN IDW IS SHEETMETAL

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
BLHDrafting
1685 Views, 10 Replies

INSERT SKETCHED SYMBOL IF PART IN IDW IS SHEETMETAL

Hi all.

 

Absolute newbie to iLogic. Hoping someone can help me with my this.

 

What I'm after is this : When a new IDW is started and the first Base view placed is of a Sheetmetal part, then a Sketched Symbol is placed at a fixed co-ordinate when Save is issued.

 

From the little iLogic I know I imagine that this would be an external rule that is triggered on Save. Any takers?

Brendan Henderson

Web www.blhdrafting.com.au
Twitter @BLHDrafting

Windows 7 x64 -64 GB Ram, Intel Xeon E5-1620 @ 3.6 GHz
ATI FirePro V7800 2 GB, 180 GB SSD & 1 TB HDD, Inv R2016 PDSU SP1 (Build 210), Vault 2016 Professional Update 1 (Build 21.1.4.0)
10 REPLIES 10
Message 2 of 11
jdkriek
in reply to: BLHDrafting

Edit: nevermind I got it 😉

 

Here we go:

 

Dim oIDW As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oIDW.ActiveSheet

' First view
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
	
	' If base view
	If oView.ViewType <> kStandardDrawingViewType Then
	
		' If ref file is sheet metal
		Dim oRefFile As Document = oIDW.ReferencedDocuments.Item(1)
		If oRefFile.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
		
			' Define which symbol
			Dim oSymDef As SketchedSymbolDefinition
			oSymDef = oIDW.SketchedSymbolDefinitions.Item("NOTES")
			
			' Set position
			Dim oPosition As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(10,10)
			
			' Insert symbol
			Dim oSymbol As SketchedSymbol
			oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition)
		End If
	End If
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 11
BLHDrafting
in reply to: jdkriek

Thanks Jonathan.

 

Is this iLogic or VBA? If iLogic is this an external rule or do I need to add it too my IDW template?

Brendan Henderson

Web www.blhdrafting.com.au
Twitter @BLHDrafting

Windows 7 x64 -64 GB Ram, Intel Xeon E5-1620 @ 3.6 GHz
ATI FirePro V7800 2 GB, 180 GB SSD & 1 TB HDD, Inv R2016 PDSU SP1 (Build 210), Vault 2016 Professional Update 1 (Build 21.1.4.0)
Message 4 of 11
matt_jlt
in reply to: BLHDrafting

Hi Brendan, looking at Jonathan's code it's iLogic, you can tell by the way the objects are set (see below). You can store the rule inside the document or as an external rule. It's up to you. With an external rule you only have to maintain one lot of code and it can be updated very easily but you have to make sure the external rule will not change location or it will throw an error every time you open a new drawing.

 

iLogic Code (can define and set it in one line)

Dim oSheet As Sheet = oIDW.ActiveSheet

 in VBA would have to be

Dim oSheet As Sheet
Set oSheet = oIDW.Activesheet

 Regards, Matt.

Message 5 of 11
jdkriek
in reply to: BLHDrafting

Matt is correct, the code I posted is iLogic (VB.NET) as you requested and it will work as an external rule or internal rule.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 6 of 11
BLHDrafting
in reply to: jdkriek

Thanks Jonathan and Matt.

 

Edit: forget it. I got past the error Smiley Happy

 

To get the symbol placed I have to manually run the rule, which is not much different from manually placing the symbol. Is there any way to get the symbol placement to occur automatically at the time the first view is placed, or on Save?.

Brendan Henderson

Web www.blhdrafting.com.au
Twitter @BLHDrafting

Windows 7 x64 -64 GB Ram, Intel Xeon E5-1620 @ 3.6 GHz
ATI FirePro V7800 2 GB, 180 GB SSD & 1 TB HDD, Inv R2016 PDSU SP1 (Build 210), Vault 2016 Professional Update 1 (Build 21.1.4.0)
Message 7 of 11
matt_jlt
in reply to: BLHDrafting

Brendan, I modified Jonathan's code so you can run it on a save as. I just added a check to make sure there is a drawing view and to see if the symbol has already been placed so it doesn't double up.

 

Dim oIDW As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oIDW.ActiveSheet

' Check that there is a view on the sheet
If oSheet.DrawingViews.Count = 0 Then Exit Sub

' First view
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
	
	' If base view
	If oView.ViewType <> kStandardDrawingViewType Then
	
		' If ref file is sheet metal
		Dim oRefFile As Document = oIDW.ReferencedDocuments.Item(1)
		If oRefFile.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
		
			' Define which symbol
			Dim oSymDef As SketchedSymbolDefinition
			oSymDef = oIDW.SketchedSymbolDefinitions.Item("NOTES")
			
			' Check if symbol has been used
			If oSymDef.IsReferenced Then Exit Sub
			
			' Set position
			Dim oPosition As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(10,10)
			
			' Insert symbol
			Dim oSymbol As SketchedSymbol
			oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition)
		End If
	End If 

 Regards, Matt.

Message 8 of 11
BLHDrafting
in reply to: matt_jlt

Thanks Matt, but it doesn't work for me. I deleted all of the existing code and copy/pasted in your update. Then I changed the "NOTES" to be the name of my symbol, and changed the Point2d values. But a Save or Save As doesn't place the symbol.

Brendan Henderson

Web www.blhdrafting.com.au
Twitter @BLHDrafting

Windows 7 x64 -64 GB Ram, Intel Xeon E5-1620 @ 3.6 GHz
ATI FirePro V7800 2 GB, 180 GB SSD & 1 TB HDD, Inv R2016 PDSU SP1 (Build 210), Vault 2016 Professional Update 1 (Build 21.1.4.0)
Message 9 of 11
matt_jlt
in reply to: BLHDrafting

Did you remember to set the code to run using the event triggers?
On the ribbon>Manage Tab>iLogic Panel>Event Triggers
It looks like two opposing angles overlapping each other.

Message 10 of 11
BLHDrafting
in reply to: matt_jlt

Remember? I didn't know I had too! I know next to nothing about iLogic.

 

But I figured it out with your directions. I set it to Before Save Document. And it works great.

 

Many thanks Matt and Jonathan.

Brendan Henderson

Web www.blhdrafting.com.au
Twitter @BLHDrafting

Windows 7 x64 -64 GB Ram, Intel Xeon E5-1620 @ 3.6 GHz
ATI FirePro V7800 2 GB, 180 GB SSD & 1 TB HDD, Inv R2016 PDSU SP1 (Build 210), Vault 2016 Professional Update 1 (Build 21.1.4.0)
Message 11 of 11
jdkriek
in reply to: BLHDrafting

I laughed a little at that last post Robot LOL

 

We often overlook the simple things that we assume everyone knows.

 

Glad you got it working.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


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

Post to forums  

Autodesk Design & Make Report