• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Visual LISP, AutoLISP and General Customization

    Reply
    Distinguished Contributor
    Posts: 202
    Registered: ‎09-04-2002

    VBA to VLISP

    255 Views, 4 Replies
    05-11-2012 01:34 AM

    Hi,

    How can i translate VBA syntax :

     

     currMenuGroup.Menus.item(i).item(j).SubMenu.item(k).Caption

     

    In VLISP

     

    I want to find a submenu in a partial menu like :

     

    TPS

         " Test"

    "Subtest-versionnumber"

    To compare the version number !

     

    Thank you very much for your help

    Daniel OLIVES

    (french user)

    Please use plain text.
    Distinguished Mentor
    Moshe-A
    Posts: 679
    Registered: ‎09-14-2003

    Re: VBA to VLISP

    05-11-2012 03:30 AM in reply to: dolives

    Daniel,

     

    ; get root pointer to menus
    (setq menuGrp (vla-get-menugroups (vlax-get-acad-object)))
    
    ; get a pointer to acad.cuix file
    (setq acadcui (vla-item menuGrp "acad"))
    
    ; get the menus
    (setq menus (vla-get-menus acadcui))
    
    ; get file menu
    (setq file-menu (vla-item menus "&File"))
    
     ; get the first  menu item
    (setq item1 (vla-item file-menu 0))
     ; get the second menu item
    (setq item2 (vla-item file-menu 2))
    .......
    .......
    ; get the fivth  menu item
    (setq item5 (vla-item file-menu 5))
    
    ; get caption
    (setq caption5 (vla-get-caption item5)) ; return "&Close"

     

    Cheers,

    Moshe

     

    Please use plain text.
    Distinguished Contributor
    Posts: 202
    Registered: ‎09-04-2002

    Re: VBA to VLISP

    05-11-2012 05:25 AM in reply to: Moshe-A

    Hi,

    Thank you for your help.

     

    I find a direct way without any control !

    (setq LabelSubMenu 
    	(vlax-get-property 
    		(vla-item 
    			(vla-get-submenu 
    				(vlax-invoke-method 
    					(vla-item 
    						(vla-get-Menus 
    							(vla-item 
    								(vla-get-MenuGroups 
    									(vlax-get-acad-object)
    								)
    								0
    							)
    						) 
    						0
    					) 
    					'Item 
    					20
    				)
    			) 
    			0
    		) 
    		'label
    	)
    )

     

    The menu index for my exemple is "20" and in submenu first so "0" !

     

    I search a best way and post it !

     

     Daniel OLIVES

     

     

    Please use plain text.
    Distinguished Contributor
    Posts: 202
    Registered: ‎09-04-2002

    Re: VBA to VLISP

    05-11-2012 05:27 AM in reply to: dolives

    HI,

    Screen shot menu !

     

    Daniel OLIVES

    Please use plain text.
    Distinguished Contributor
    Posts: 202
    Registered: ‎09-04-2002

    Re: VBA to VLISP

    05-11-2012 05:33 AM in reply to: dolives

    Hi,

    I use this way to an automatic reload of mpartial menu when I update it.

    I control if the labet of version is correct and if not i reload !

    It work in VBA, but before migrate to dot net, i convert all in VLISP !

    It is a good exercice !

    Because i think it is very important to know how do al things in VLISP or LISP in AutoCAD so after it was easy to know how is possible or not !

     

    Daniel OLIVES

     

    Please use plain text.