oControlDef = ThisApplication.CommandManager.ControlDefinitions("PartiFeatureIns

oControlDef = ThisApplication.CommandManager.ControlDefinitions("PartiFeatureIns

Anonymous
Not applicable
2,303 Views
5 Replies
Message 1 of 6

oControlDef = ThisApplication.CommandManager.ControlDefinitions("PartiFeatureIns

Anonymous
Not applicable

hi!

 

i use ThisApplication.CommandManager.ControlDefinitions("PartiFeatureInsertCmd")

and i want to have the name of iFeature selection with ilogic?

 

Thanks for your help 🙂

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

frederic.vandenplas
Collaborator
Collaborator

 Hi,

 

You can send extra information to a command (if you see it as a selectionset before activating a command)

This page explains alot about the commandmanager

http://modthemachine.typepad.com/my_weblog/2009/03/running-commands-using-the-api.html

And you need something like this

Public Sub PlacePart() 
    ' Get the command manager. 
    Dim oCommandMgr As CommandManager 
    Set oCommandMgr = ThisApplication.CommandManager 

    ' Post the filename. 
    Call oCommandMgr.PostPrivateEvent(kFileNameEvent, _ 
         "C:\Users\ekinsb\Documents\Inventor 2010\Showcasetest.ipt") 

    ' Get control definition for the place component command. 
    Dim oControlDef As ControlDefinition 
    Set oControlDef = oCommandMgr.ControlDefinitions.Item( _  
                                    "AssemblyPlaceComponentCmd")  

    ' Execute the command. 
    Call oControlDef.Execute 
End Sub
If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 3 of 6

Anonymous
Not applicable

thanks for your reply Frederic!

 

I see this link before but nothing about what i"m looking for!

 

Sorry for my English 😞

0 Likes
Message 4 of 6

Anonymous
Not applicable

The code i try to make!

 

SyntaxEditor Code Snippet

Dim oDoc As Document
Dim oCompDef As PartComponentDefinition
oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oiFeatComp As iFeatureComponent

' Get the command manager.
Dim oCommandMgr As CommandManager 
oCommandMgr = ThisApplication.CommandManager

'Get control definition
Dim oControlDef As ControlDefinition 
oControlDef = ThisApplication.CommandManager.ControlDefinitions("PartiFeatureInsertCmd")

' Execute the command synchronously.  
Call oControlDef.Execute2(True) 

Dim strPrompt As String 
strPrompt = oiFeatComp.Name 
iProperties.Value("Custom", "TEST") = strPrompt

 

I want the name of iFeature who is selected by the user.

 

 

ifeature.JPG 

0 Likes
Message 5 of 6

frederic.vandenplas
Collaborator
Collaborator
Accepted solution

Hi,

 

This code does what you where looking for, only you need to create a few lines of code to extract the filename.

now the full path is created in the iproperties.

 

I found it through debugging in vba, which you wont find easy in help or in ilogic

Dim oDoc As Document
Dim oCompDef As PartComponentDefinition
oCompDef = ThisApplication.ActiveDocument.ComponentDefinition

' Get the command manager.
Dim oCommandMgr As CommandManager
oCommandMgr = ThisApplication.CommandManager

'Get control definition
Dim oControlDef As ControlDefinition
oControlDef = ThisApplication.CommandManager.ControlDefinitions("PartiFeatureInsertCmd")

' Execute the command synchronously.
Call oControlDef.Execute2(True)

Dim oiFeatComp As iFeature
oiFeatComp = oCompDef.Features.iFeatures(oCompDef.Features.iFeatures.Count)

Dim strPrompt As String
strPrompt = oiFeatComp.iFeatureTemplateDescriptor.LastKnownSourceFileName

iProperties.Value("Custom", "TEST") = strPrompt
If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
Message 6 of 6

Anonymous
Not applicable

thank you very much Frederic 🙂

0 Likes