iLogic "Place ilogic component"

iLogic "Place ilogic component"

robertast
Collaborator Collaborator
2,618 Views
5 Replies
Message 1 of 6

iLogic "Place ilogic component"

robertast
Collaborator
Collaborator

Is it possible to run the "Add ilogic component" command with iLogic?
But choose how to give it a name. By default, the suffix –01, –02, –03,… is created. (Bushing-01.ipt)
Is it possible to add the prefix "01-Bushing.ipt"?

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

WCrihfield
Mentor
Mentor

Here is how to launch the command (in reference to your first question).

ThisApplication.CommandManager.ControlDefinitions.Item("iLogic.PlaceComponent").Execute

However, that alone wont do the naming prefix for you.

When the dialog first opens, the 'focus' is usually already on the file name text box, and it is empty, awaiting your entry.

You may be able to use the PostPrivateEvent() Sub to place a predefined file name into that text box, as you may have seen others to with the SaveAs FileDialog examples.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

robertast
Collaborator
Collaborator

@WCrihfield 

Thanks for answering someone. This code as I found, but thanks anyway.
The most relevant question for me is how to force those auto numbers to be written before the name.

Or maybe you can fill in the code with PostPrivateEvent (). Maybe it will meet my wishes

 

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor

I have used this method with the Save or Open FileDialog codes before, and it works, but I had not tried using it in this situation yet, when I posted, but it sounded like it might work too.

Unfortunately, when I tried it that way with the following code it didn't work, for some reason.

Dim oPath As String = ThisDoc.Path
Dim oOldName As String = ThisDoc.FileName(False)
Dim oPrefix As String = "01-"
Dim oNewFullName As String = oPath & "\" & oPrefix & oOldName & ".ipt"
'This writes this string onto the Clipboard (understood as a filename).
ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oNewFullName)
ThisApplication.CommandManager.ControlDefinitions.Item("iLogic.PlaceComponent").Execute

I think it may have something to do with loss of system 'focus', but I'm not sure.

However, there may be another route to do this, without using executing this command.

You're familiar with using the following code right?:

Component.Visible("ComponentName") = False 'or True
'and
Component.Replace()

Well, how this newer function?

Components.Add()

ThisRule.Components (this is a IManagedComponents object, and you don't need to put ThisRule in front of it.)

It provides the Add, AddiPart, AddContentCenterPart, Delete and other functions in iLogic Assemblies.

I generally don't use the "Place iLogic Component" tool, due to how our filing system is set-up, so I haven't messed with it very much.  In Inventor 2021, within the iLogic rule editor dialog > Snippets > System tab > iLogic Assemblies/Components > there are 12 snippets, one of which is called "Add Component".  Below is the code within:

Dim componentA = Components.Add("a:1", "a.ipt", position := Nothing, grounded := False, visible := True, appearance := Nothing)

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 6

robertast
Collaborator
Collaborator

@WCrihfield 

If you have a vault, you may not need a command. And it is quite convenient for me to move the workpiece blank to a new assembly. It creates a new sub-assmbly by including the iLogic in it.

It is only because of this at the end of the appendix that the catalog looks poor, it is inconvenient to look for details when making drawings.

Message 6 of 6

robertast
Collaborator
Collaborator
Accepted solution

Thanks to everyone who tried to help me, as well as to those who did so by writing personal messages.

I seem to have found a way to solve this problem.
We launch a second, empty inventor. Because otherwise we will not have access to the "Coy iLogic project".
And the second generation is that you don’t have to close the model you’re working on (so faster).
Coy iLogic Project not only allows you to select various settings, but also copies the idw template, if any.

Project iLogic.png

 Maybe this process could be described with iLogic, but I only know one person who can do it. 😉