What is the command (in the source code) to draw and place a new symbol from the library to Eeschema schematic

I’m not sure if this is the right place for this question, but here goes:
Is there a specific file or function in the source code that tells us how to place a symbol from the library to the schematic board?

The developers mailing list would be better place for questions about source code, although some developers read this forum occasionally.

Okay. Thank you for bringing me there. Should I send an email to the developers?
Best wishes.

I wouldn’t email the developer list just yet. Let us help you hone your question. Find the source code repo and look for the Place symbol menu item, or add symbol menu item. What are you trying to accomplish?

1 Like

Hi Greg,
Thank you! So I have tried the following steps:

  1. I went to the file “dialogs/choose_component.cpp” which is where the “Place symbol” menu functions are defined.
  2. However, from there, I could not narrow down the function that dictates what happens when you either double click on an item in the library or you press Save, because the OK button is bound to the “SetDefault()” function and the double click is bound to a timer function (which, even if I comment out, still allows me to place the component on the schematic).
  3. I tried searching what happens when one places a “text” or a wire, which led me to the files “sch_base_frame” and “run_action->Cursor_Click”, neither of which I could find the function that dictates how to draw and click.
  4. I’m not too sure where to go from here. My main goal is to be able to click a button that I have created (in a new dialog box) and from there, have a component drawn and placed on the schematic.
    Cheers.

OK. This is good. So you want to create a set of quick icons that “preselect” the component and put eeschema in the mode where a mouse click places this preselected symbol?

1 Like

Yes, that sounds correct. Do you know where I can find the functions to do that?

I don’t know for sure, but I found this file where there is a function that checks aPreselectedLibId.IsValid() so one path might be to set aPreselectedLibId and setting it as valid prior to calling a function I’ve yet to find.

Okay. I had seen that function (well, the SetSelectedComponent) function, but hadn’t quite tested it yet. I’ll start from there and see how it goes and update this thread along the way.
Cheers.

Sounds great! I’ll be watching the thread and help where I can.

1 Like

Update: In “sch_drawing_tools.cpp”, under the function “PlaceComponent”, there’s an else statement that calls the function “AddItemToScreenAndUndoList( component );”. This is the function that places the component on the sheet!

1 Like

I’m so glad you were able to find it!

Yes, but now I still need to find the function that draws the component and then places it! :slight_smile:

It’s probably in the thread of code from the mouse click that calls the dialog for getting component from library. After hitting OK (or double clicking the component in the list). Basically you’re trying to sidestep the component selection dialog, right?

Yes, precisely. I’m looking through the “dialog_choose_component.cpp” file to see what I can find. I think that will lead me somewhere.

Do you have any other suggestions? I feel at a lost right now.
I’m basically trying, now, to select a component from a library list and place it onto the schematic, but bypassing the component selection dialog.

Didn’t you get a quick response on mailing list from the expert on the matter?
https://lists.launchpad.net/kicad-developers/msg43376.html

Why not follow up there?
I think this is what you are looking for: https://gitlab.com/kicad/code/kicad/blob/9f7e0ef8e8daa4c1d3e7d566da18e1fd5b6e92f6/eeschema/tools/sch_drawing_tools.cpp#L192

Agreed, you have enough detail and investigation to follow up on the dev mailing list. You’re making progress, at least!

1 Like

Oh my goodness! I didn’t know that I had a response on the mailing list because I thought I would get an email notification about it. Oops! My apologies.
Thank you for pointing this out to me.
I have indeed looked at both these files, but I believe I need to take an even closer look at them.
Cheers.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.