Control Definition Not Receiveing Selection Set

Control Definition Not Receiveing Selection Set

MechMachineMan
Advisor Advisor
459 Views
3 Replies
Message 1 of 4

Control Definition Not Receiveing Selection Set

MechMachineMan
Advisor
Advisor

I've got the code below; 

 

The control works fine when I select the object manually and run it, but when I try to get the program to select it, it does not run.

 

I've tried analyzing objects in the vba environment, and it looks like everything is as expected.... The control definition is just not receiving/processing the select set object.

 

What is going wrong/how do I fix this/how do I figure out how to fix this?

 

Thanks,

 

- Justin

 

 

Attached:

 

'Vb.net 'Dim oDoc As Document'oDoc = ThisApplication.ActiveDocument'
'Dim oSS As SelectSet'oSS = oDoc.SelectSet'
'oSS.Select(oDoc.ActiveSheet.DrawingNotes.GeneralNotes.Item(1))'
'oDoc.Update'
'Dim oCommandMgr As CommandManager'oCommandMgr = ThisApplication.CommandManager'
'Dim oControlDef1 As ControlDefinition'oControlDef1 = oCommandMgr.ControlDefinitions.Item("DrawingGeneralNoteEditCtxCmd")'oControlDef1.Execute2(True)

'vba
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oSS As SelectSet
Set oSS = oDoc.SelectSet

oSS.Select(oDoc.ActiveSheet.DrawingNotes.GeneralNotes.Item(1))

oDoc.Update

Dim oCommandMgr As CommandManager
Set oCommandMgr = ThisApplication.CommandManager

Dim oControlDef1 As ControlDefinition
Set oControlDef1 = oCommandMgr.ControlDefinitions.Item("DrawingGeneralNoteEditCtxCmd")
oControlDef1.Execute2(True)

 


--------------------------------------
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
460 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant

@MechMachineMan, I was just trying to do something similar.

 

Do you ( or anyone else who happens to read this) know how to get this to work?

 

Or know of another way to open the text editor dialog of a code selected general note?

 

I noticed it works as expected if the item is preselected, or if the interactively selected item is a leader note.

 

But not if we try to select a general note via code.

 

@MjDeck , @chandra.shekar.g can you tell us if there is bug here?

 

see attached Inventor 2022 example file.

 

Preselect the leader note, run the internal rule: works as expected

Preselect the general note, run the internal rule: works as expected

Clear the selection set, run the internal rule and select a leader note interactively: works as expected

Clear the selection set, run the internal rule and select a general note interactively: does not work

 

Dim oSSet As SelectSet = ThisApplication.ActiveDocument.SelectSet

If oSSet.Count = 0 Then

	Try
		oNoteBox = ThisApplication.CommandManager.Pick(Inventor.SelectionFilterEnum.kDrawingNoteFilter, "Select text object.")
		oSSet.Select(oNoteBox)

	Catch ex As Exception

		MsgBox(ex.Message)
	End Try
Else
	oNoteBox = oSSet.Item(1)
End If


If Not oNoteBox Is Nothing Then

	If oSSet.Item(1).Type = ObjectTypeEnum.kGeneralNoteObject Then
		ThisApplication.CommandManager.ControlDefinitions.Item("DrawingGeneralNoteEditCtxCmd").Execute
	ElseIf oSSet.Item(1).Type = ObjectTypeEnum.kLeaderNoteObject Then

		ThisApplication.CommandManager.ControlDefinitions.Item("DrawingLeaderEditTextCtxCmd").Execute
	End If
Else
	MsgBox("oNoteBox = nothing")
End If
					

 

EESignature

0 Likes
Message 3 of 4

MjDeck
Autodesk
Autodesk

@Curtis_Waguespack , yes there is a bug. Thanks for investigating this. It is internal number INVGEN-65247. It looks like it's easy to fix.
I don't see a workaround other than pre-selecting the general note before you run the rule.


Mike Deck
Software Developer
Autodesk, Inc.

Message 4 of 4

Curtis_Waguespack
Consultant
Consultant

 @MjDeck, Thank you for taking a look at this and confirming the issue.

 

Unfortunately, I have a customer that has a requirement for this for a drawing automation tool using Inventor 2023. 

 

I'll try and figure out a different workflow, but if a fix for this were to end up in a future update to Inventor 2023 that would be outstanding 😉 ( I know you can't comment on future updates, etc) 

 

Thanks again.

EESignature

0 Likes