How to insert a drawing via Ribbon Bar Button?

How to insert a drawing via Ribbon Bar Button?

Anonymous
Not applicable
1,442 Views
5 Replies
Message 1 of 6

How to insert a drawing via Ribbon Bar Button?

Anonymous
Not applicable

Since digging into the doing my ribbon bar in .Net vs the CUI interface (ugg) and finally got a ribbon bar up and working now my next issue arised.

 

Trying to insert a block via the ribbon bar.  Now in the CUI it runs a macro though in my code I can't get it to do 2 commands at once (Insert and Block.dwg).  Before I could use the code ^C^CInsert Block.dwg S1 R0 and then I could select where the block would be put into the drawing.

 

How would I got about this?

 

Example code of the panel tab where im trying to add this.

 

 

    Private Sub addBCM1Chain(ByVal ribTab As RibbonTab)
        'Create the panel source 
        Dim ribSourcePanel As RibbonPanelSource = New RibbonPanelSource()
        ribSourcePanel.Title = "1 Chain"
        'Create the panel 
        Dim ribPanel As New RibbonPanel()
        ribPanel.Source = ribSourcePanel
        ribTab.Panels.Add(ribPanel)
        'Create a button 
        Dim ribBtn As Autodesk.Windows.RibbonButton = New RibbonButton()
        ribBtn.Text = "Net load"
        ribBtn.CommandParameter = "Insert|Block.dwg"
        ribBtn.Orientation = Windows.Controls.Orientation.Vertical
        ribBtn.Size = RibbonItemSize.Large
        ribBtn.LargeImage = LoadImage("Block.png")
        ribBtn.ShowImage = True
        ribBtn.ShowText = True
        ribBtn.CommandHandler = New AdskCommandHandler()
        'Add the button
        ribSourcePanel.Items.Add(ribBtn)
    End Sub

 

 

0 Likes
1,443 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Was able to get a little somewhere with it but still not as clean cut as the macro's inside AutoCAD.

 

Replaced this line

 ribBtn.CommandParameter = "-Insert 01M_Antriebsst_0500"

 

Now when I click it I get this

Command: -Insert Enter block name or [?] <01M_Antriebsst_0500>:

 

Right click and come up to

01M_Antriebsst_0500
Units: Unitless   Conversion:      1.00
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]:

 

Which leaves this then.. to be either clicked or not

Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>:
Enter Y scale factor <use X scale factor>:
Specify rotation angle <0.0000>:

 

I'd like to limit it down to 1 click.  Doing the macro "^C^CInsert Block.dwg S1 R0" inside Autocad I click the button and I have the option to rotate, select new basepoint and such but I can just left click and it will add it to the drawing.  So a 2 click deal.  Vers a 5 clicks currently.

0 Likes
Message 3 of 6

Anonymous
Not applicable

Deathman,

 

You should always place a space after the command. Like this. "InvokeCommand "

 

But are the block always in the drawing? What happens if the block purged out of the drawing?

 

I think it would be better to create a function that checks if the blocktableRecord has a block with name 'X'

if not insert it from your libray en then let the user pick a point and lat him specify the rotation angle. Or not.

 

Kind regards,

 

Irvin

0 Likes
Message 4 of 6

Anonymous
Not applicable

Irvin ,

 

No blocks in the drawing.  These are being pulled out a directory located on our harddrives.  The directory is called out in the autocad profile reference directories already.

 

The command does work but it just takes extra steps right now to get it in, instead of an 2 click method it takes 5.

 

If I add the "& vbCrLf &"  I can fill in more info but it automatically places the block since one  of the first things is to select a point to drop in the block.  Is there a function to have it wait for a mouse click?

 

Right now I have it like this

 

ribBtn.CommandParameter = "-Insert Block" & vbCrLf & "1" & vbCrLf & "1" & vbCrLf

 

This doesn't enter it at a 0,0 location but picks some point off where you last clicked at least on the drawing.  Kind of screwy but it does get it in there.  Just curious if there is a way to clean it up a little more where I can actually select my point where I want this block to drop that works within the code.  I've tried searching for anything dealing with it but it all seems to relate to LISP's/Macro's,  a little VB here and there but not at all dealing with ribbon bars and command line type function.

0 Likes
Message 5 of 6

Anonymous
Not applicable

As well what would be really nice is if I could use the plain "Insert" command that brings up the block inserter box, though if I continue with the command line text isn't entered into the box.  Just sort of craps out there at the insert window.

0 Likes
Message 6 of 6

Anonymous
Not applicable

Anyone have any suggestions?

 

Trying to figure out how to do this but running into a block with the commands I have above.  I need something that tells it to wait for user input in the command line then I should be able to get it to work properly... i think.  Or ability to make it type something inside the insert block menu.

0 Likes