Recent Posts

Pages: [1] 2 3 ... 10
1

That's a tough question.

You'll probably get more people using VB at the other place you've posted this.

If it was C# I'd ask you for the complete solution file and everything that goes with it. ( ie, something compilable and with ALL resources )

I seem to recall that you've asked this sort of question before ... about toolbars located in a specific location ..
2
Hi All,

I wrote some DOT NET routines a while back in AutoCAD 2010 using Visual Studio 2010, but now we are upgrading to AutoCAD 2017 / Visual Studio 2015.

I have successfully imported all of my code into the new environment, and everything works fine, except for the flyouts, toolbars, and toolbar buttons. These do not even show up at all in AutoCAD 2017 after the program is started up and my DLL is netloaded.
All the commands, however, still become available in AutoCAD, but only via command line.

What I'm attempting to accomplish is to have the flyouts appear automatically on the top-left everytime AutoCAD is started up.

Below is the myCommands.vb file which runs upon program initialization, and which should show me my flyouts in AutoCAD 2017, but doesn't:


Option Explicit On
Imports Microsoft.Win32
Imports System.Reflection
Imports System.Data.OleDb
Imports System.Runtime.CompilerServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports acApp = Autodesk.AutoCAD.ApplicationServices.Application
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Customization
Imports acOp = Autodesk.AutoCAD.Interop
Imports acOpCom = Autodesk.AutoCAD.Interop.Common

<Assembly: CommandClass(GetType(CatScript17.CatScriptCommands))>
Namespace CatScript17
    ' Manages all CatScript commands for this software. Also contains all the autocad flyout/toolbar commands.
    Public Class CatScriptCommands
        Implements IExtensionApplication
        Public Shared strAppName As String = "CatScript17"
        Public Shared cs As CustomizationSection
        Public Shared restoreDefaultMacro As Boolean = False

        Public Sub Initialize() Implements IExtensionApplication.Initialize
            ' Autoload the catscript17 flyouts and toolbars into AutoCAD 2017 upon each startup
            CatScriptToolbar.addToolbar()
        End Sub

        Public Sub Terminate() Implements IExtensionApplication.Terminate
            Throw New NotImplementedException()
        End Sub

        ' Displaying the Air Conveyor Corner form
        <CommandMethod("accorner", CommandFlags.UsePickSet)>
        Public Shared Sub acCorner()
        End Sub

        ' Displaying the Air Conveyor Side Elevation form
        <CommandMethod("acelevation", CommandFlags.UsePickSet)>
        Public Shared Sub acElevation()
        End Sub

        ' Displaying the Air Conveyor Straight form
        <CommandMethod("acstraight", CommandFlags.UsePickSet)>
        Public Shared Sub acStraight()
        End Sub

        ' Displaying the Case Straight Combo form
        <CommandMethod("cccombo", CommandFlags.UsePickSet)>
        Public Shared Sub ccCombo()
        End Sub

        ' Displaying the Case Corner Conveyor form
        <CommandMethod("cccorner", CommandFlags.UsePickSet)>
        Public Shared Sub ccCorner()
        End Sub

        ' Displaying the Case Conveyor Side Elevation form
        <CommandMethod("ccelevation", CommandFlags.UsePickSet)>
        Public Shared Sub ccElevation()
        End Sub

        ' Displaying the Case Straight Conveyor form
        <CommandMethod("ccstraight", CommandFlags.UsePickSet)>
        Public Shared Sub ccStraight()
        End Sub

        ' Displaying the Case Turner Conveyor form
        <CommandMethod("ccturner", CommandFlags.UsePickSet)>
        Public Shared Sub ccTurner()
        End Sub

        ' Displaying the Case Zero Pressure Conveyor form
        <CommandMethod("cczeropressure", CommandFlags.UsePickSet)>
        Public Shared Sub ccZeroPressure()
        End Sub

        ' Displaying the table top Bi-Di form
        <CommandMethod("ttbidi", CommandFlags.UsePickSet)>
        Public Shared Sub ttBiDi()
        End Sub

        ' Displaying the table top Combiner form
        <CommandMethod("ttcombiner", CommandFlags.UsePickSet)>
        Public Shared Sub ttCombiner()
        End Sub

        ' Displaying the table top Corner form
        <CommandMethod("ttcorner", CommandFlags.UsePickSet)>
        Public Shared Sub ttCorner()
        End Sub

        ' Displaying the table top Decel form
        <CommandMethod("ttdecel", CommandFlags.UsePickSet)>
        Public Shared Sub ttDecel()
        End Sub

        ' Displaying the table top Divert form
        <CommandMethod("ttdivert", CommandFlags.UsePickSet)>
        Public Shared Sub ttDivert()
        End Sub

        ' Displaying the table top Dynamic form
        <CommandMethod("ttdynamic", CommandFlags.UsePickSet)>
        Public Shared Sub ttDynamic()
        End Sub

        ' Displaying the Table Top Side Elevation form
        <CommandMethod("ttelevation", CommandFlags.UsePickSet)>
        Public Shared Sub ttElevation()
        End Sub

        ' Displaying the Mass Merge Conveyor form
        <CommandMethod("ttmerge", CommandFlags.UsePickSet)>
        Public Shared Sub ttMerge()
        End Sub

        ' Displaying the Mass Parallel Conveyor form
        <CommandMethod("ttparallel", CommandFlags.UsePickSet)>
        Public Shared Sub ttParallel()
        End Sub

        ' Displaying the Mass Straight Conveyor form
        <CommandMethod("ttstraight", CommandFlags.UsePickSet)>
        Public Shared Sub ttStraight()
        End Sub
    End Class

    Public Class CatScriptToolbar
        '-----------
        ' Properties
        '-----------
        Private Shared groups As acOp.AcadMenuGroups
        Private Shared group As acOp.AcadMenuGroup
        Private Shared toolbars As acOp.IAcadToolbars
        Private Shared toolbar As acOp.AcadToolbar
        Private Shared flyout As acOp.AcadToolbarItem
        '--------
        ' Methods
        '--------
        ' Component for adding toolbars and flyouts
        Public Shared Sub addToolbar()
            Try
                Dim app As acOp.AcadApplication = _
                DirectCast(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication,  _
                acOp.AcadApplication)

                ' Define the toolbars group
                groups = app.MenuGroups
                group = groups.Item(0)
                toolbars = group.Toolbars

                ' Generate the flyout toolbar
                toolbar = toolbars.Add("CatScript Tools")

                ' Generate the flyouts
                flyoutForTableTop(0)
                flyoutForCaseConveyor(1)
                flyoutForAirConveyor(2)

                ' Dock the newly created toolbar on the left
                toolbar.Dock(acOpCom.AcToolbarDockStatus.acToolbarDockLeft)

            Catch ex As System.Exception
            End Try
        End Sub

        ' Component for generating the flyout for air conveyor, as well as buttons for each routine
        Private Shared Sub flyoutForAirConveyor(ByVal toolbarIndex As Long)
            ' Create an air conveyor toolbar
            Dim str As String = "Air"
            Dim tool As acOp.AcadToolbar = toolbars.Add(str & " Conveyor")
            Dim titles(), commands(), descs() As String

            titles = {"Straight", "Corner", "Elevation"}
            commands = {"straight", "corner", "elevation"}

            descs = {"Generates the straight sections for air conveyor applications. " & _
                     "Allows for section dimensioning",
                     "Generates the curved sections and corners for air conveyor applications " & _
                     "(in angles of 30, 45, 60, and 90 degrees). User also has the option of generating " & _
                     "infinite curves (with legs or hangers) for the air conveyor corner",
                     "Generates the side and plan views of elevation changes for air conveyors. " & _
                     "This is accomplished using infeed and discharge NRE, incline/decline angle or " & _
                     "specified/picked distance, and infeed/discharge section lengths. This routine " & _
                     "allows for section dimensioning (if generating ONLY plan view)"}

            Dim button As acOp.AcadToolbarItem
            For i As Long = 0 To titles.Length - 1
                ' Add the button to temporary toolbar
                button = tool.AddToolbarButton(i, str & " " & titles(i), _
                descs(i), ChrW(27) & ChrW(27) & "_ac" & commands(i) & vbLf, False)

                ' Set the images for the button. cat.root is C:\catscript\
                button.SetBitmaps(cat.root & "AC " & titles(i) & ".bmp", _
                                  cat.root & "AC " & titles(i) & ".bmp")
            Next

            'Create the Group flyout
            flyout = toolbar.AddToolbarButton(toolbarIndex, _
                "Air Conveyor", "Groups the Air Conveyors", _
                ChrW(27) & ChrW(27) & "_acstraight" & vbLf, True)
            flyout.SetBitmaps(cat.root & "AC Straight.bmp", cat.root & "AC Straight.bmp")

            ' Attach the group toolbar to the flyout just created
            flyout.AttachToolbarToFlyout(group.Name.ToString(), str & " Conveyor")
            tool.Visible = False
        End Sub

        ' Component for generating the flyout for case conveyor, as well as buttons for each routine
        Private Shared Sub flyoutForCaseConveyor(ByVal toolbarIndex As Long)
            ' Create a case conveyor toolbar
            Dim tool As acOp.AcadToolbar = toolbars.Add("Case Conveyor")
            Dim titles(), commands(), descs() As String

            titles = {"Straight", "Corner", "Turner", "Zero Pressure", "Elevation", "Combo"}
            commands = {"straight", "corner", "turner", "zeropressure", "elevation", "combo"}

            descs = {"Generates the straight sections for case conveyor applications. " & _
                     "Sections generated are Straight Idler, Pass Through, Drive, and Stand Alone, " & _
                     "using varying infeed and discharge styles. This routine allows " & _
                     "for section dimensioning",
                     "Generates the curved sections and corners in case conveyor applications",
                     "Generates the Straight Stand-Alone, and Multiple Chain sections of case " & _
                     "conveyor for product orientation change. This routine allows for section dimensioning",
                     "Generates straight sections of Zero-Pressure Accumulation in case " & _
                     "conveyor applications. This routine allows for section dimensioning",
                     "Generates the side and plan views of elevation changes for case conveyors. " & _
                     "This is accomplished using infeed and discharge TOC, incline/decline angle or " & _
                     "specified/picked distance, and infeed/discharge section lengths. This routine " & _
                     "allows for section dimensioning (if generating ONLY plan view)", _
                     "Combines two or three case straight sections into one case straight section"}

            ' Add the button to temporary toolbar
            Dim button As acOp.AcadToolbarItem
            For i As Long = 0 To titles.Length - 1
                button = tool.AddToolbarButton(i, "Case " & titles(i), _
                descs(i), ChrW(27) & ChrW(27) & "_cc" & commands(i) & vbLf, False)

                ' Set the images for the button
                button.SetBitmaps(cat.root & "CC " & titles(i) & ".bmp", _
                                  cat.root & "CC " & titles(i) & ".bmp")
            Next

            'Create the Group flyout
            flyout = toolbar.AddToolbarButton(toolbarIndex, _
                "Case Conveyor", "Groups the Case conveyors", _
                ChrW(27) & ChrW(27) & "_ccstraight" & vbLf, True)
            flyout.SetBitmaps(cat.root & "CC Straight.bmp", cat.root & "CC Straight.bmp")

            ' Attach the group toolbar to the flyout just created
            flyout.AttachToolbarToFlyout(group.Name.ToString(), "Case Conveyor")
            tool.Visible = False
        End Sub

        ' Component for generating the flyout for table top, as well as buttons for each routine
        Private Shared Sub flyoutForTableTop(ByVal toolbarIndex As Long)
            ' Create a table top toolbar
            Dim tool As acOp.AcadToolbar = toolbars.Add("Table Top")
            Dim titles(), commands(), descs() As String

            titles = {"Straight", "Corner", "Dynamic Transfer", "Parallel Transfer", _
                       "Merge", "Divert", "Combiner", "Decel"}
            commands = {"straight", "corner", "dynamic", "parallel", _
                        "merge", "divert", "combiner", "decel"}

            descs = {"Generates the straight sections for table top applications. " & _
                     "Sections generated are Straight Idler, Pass Through, Drive, and " & _
                     "Stand Alone. User has the option of specifying rail configuration, " & _
                     "using varying infeed and discharge styles. This routine allows " & _
                     "for section dimensioning",
                     "Generates the curved sections and corners in table top applications.",
                     "Generates the dynamic transfer sections in table top applications. " & _
                     "User has the option of specifying rail configuration. " & _
                     "This routine allows for section dimensioning",
                     "Generates the parallel transfers in table top applications. User has the " & _
                     "option of specifying rail configuration. This routine allows for section dimensioning",
                     "Generates merge tables in table top applications. User has the option of " & _
                     "specifying rail configuration. This routine allows for section dimensioning",
                     "Generates divert tables in table top applications. User has the option of " & _
                     "specifying rail configuration. This routine allows for section dimensioning",
                     "Generates combiner tables in table top applications. " & _
                     "This routine allows for section dimensioning",
                     "Generates deceleration tables in table top applications. " & _
                     "This routine allows for section dimensioning"}

            ' Generate the buttons
            Dim button As acOp.AcadToolbarItem

            For i As Long = 0 To titles.Length - 1
                ' Add the button to temporary toolbar
                button = tool.AddToolbarButton(i, "Table Top " & titles(i), _
                descs(i), ChrW(27) & ChrW(27) & "_tt" & commands(i) & vbLf, False)
                ' Set the images for the button
                button.SetBitmaps(cat.root & "TT " & titles(i) & ".bmp", _
                                  cat.root & "TT " & titles(i) & ".bmp")
            Next

            'Create the Group flyout
            flyout = toolbar.AddToolbarButton(toolbarIndex, _
                "Table Top Conveyor", "Groups the Table Top conveyors", _
                ChrW(27) & ChrW(27) & "_ttstraight" & vbLf, True)
            flyout.SetBitmaps(cat.root & "TT Straight.bmp", cat.root & "TT Straight.bmp")

            ' Attach the group toolbar to the flyout just created
            flyout.AttachToolbarToFlyout(group.Name.ToString(), "Table Top")
            tool.Visible = False
        End Sub
    End Class
End Namespace


This project references the latest AutoCAD API DLLs from ObjectARX 2017.

Any ideas on how I can get this code to display those 3 flyouts and their toolbars?
Did AutoCAD change the way flyouts and toolbars are generated in AutoCAD 2017 VS2015?
If so, any pointers as to how I can autoload my flyouts and toolbars in AutoCAD 2017 upon program startup?

Thanks.
3
AutoLISP (Vanilla / Visual) / Re: Change Value Attributes
« Last post by T.Willey on February 24, 2017, 05:57:29 pm »
Ssget, No.  ssget will select "space" entities, not nested entities.  Use ssget to select the blocks, then step through the attributes ob the selected blocks (testing the tag) and make the changes there.

The code I linked to will allow you to select the attribute entities like ssget.

So you have two options on how to get to the attributes within a block now.  Choose which way works for you.  Post code once you get stuck.
4
AutoLISP (Vanilla / Visual) / Re: Change Value Attributes
« Last post by amc.dicsac on February 24, 2017, 05:51:27 pm »
NO, the block has two attributes the first tag1 and the other tag2, the tag1 I want to add 33 and the tag2 subtract 4, I do not want to apply entsel because I would have to select one by one that is why I asked if ssget could extract the content Of the attributes.
5
AutoLISP (Vanilla / Visual) / Re: Change Value Attributes
« Last post by T.Willey on February 24, 2017, 05:38:19 pm »
Do you want to select the attributes themselves?  If so, take the code from here.
6
AutoLISP (Vanilla / Visual) / Re: Change Value Attributes
« Last post by Grrr1337 on February 24, 2017, 05:15:44 pm »
Here are numerous ways:
http://www.lee-mac.com/attributefunctions.html
When you're stuck at learning LISP always check Lee Mac's stuff (IMO hes the best learning material). :D
7
AutoLISP (Vanilla / Visual) / Re: Change Value Attributes
« Last post by amc.dicsac on February 24, 2017, 05:03:45 pm »
H Ronjonp i, how are you

This subfunction I found in this link would probably work with ssget
https://www.theswamp.org/index.php?topic=49300.msg543974#msg543974

Code - Auto/Visual Lisp: [Select]
  1. (defun _putattvalue (block tag value / att flag)
  2.    (foreach att (vlax-invoke block 'getattributes)
  3.      (if (eq (strcase tag) (strcase (vla-get-tagstring att)))
  4. att
  5. (if (= (type value) 'str)
  6.   value
  7.   (vl-princ-to-string value)
  8. )
  9.       )
  10.       (setq flag value)
  11. )
  12.      )
  13.    )
  14.    flag
  15.  )
8
AutoLISP (Vanilla / Visual) / Re: Change Value Attributes
« Last post by ronjonp on February 24, 2017, 04:53:02 pm »
There are hundreds of examples here.
9
AutoLISP (Vanilla / Visual) / Change Value Attributes
« Last post by amc.dicsac on February 24, 2017, 04:40:34 pm »
Hi, how are you

Is there any subfunction that allows you to select blocks with attributes and change them automatically

Thank you
10
AutoLISP (Vanilla / Visual) / Re: Translating Batch files to Lisp files
« Last post by Master_Shake on February 24, 2017, 03:46:02 pm »
What does not currently work?
Pages: [1] 2 3 ... 10