Jump to content

Visual Lisp & AutoCAD Mechanical


Recommended Posts

Posted

How do I connect to and use AutoCA mechanical API using Visual Lisp.

 

I have tried hard but can't find how to do this.

 

Plrase help.

Posted

To see how AutoLISP interact with AutoCAD, I suggest you to follow a tutorial - the one at AfraLISP for example.

For a more precise response, it will be useful to describe what you are intending to automate.

Posted

Thank you but I am talking of AutoCAD Mechanical.

 

I am trying to add balloons using visual lisp.

Posted

I'm inferring a bit here, from old VBA experience, but what happens if this is used?

 

(setq symBB (vla-getinterfaceobject (vlax-get-acadobject)"SymBBAuto.McadSymbolBBMgr.3"))

Posted

Being entirely unfamiliar with Mechanical specifically, your best best is to look at the ActiveX (COM) API Documentation (either VBA, or .NET)... So long as Mechanical supports that, many/most/all? of those Objects, Properties, and Methods will be available via LISP (generally speaking).

Posted

I already tried that but it gives me error

; error: Automation Error. Problem in loading application

 

Also documentation does not explain this. Once I can get hold of the symb object, then VBA documentation can help.

Posted

This is an example of adding a civ3d point it should be similar for Mechanical open database then open subset and add. The hardest thing is finding variable names for gets & puts. Google a fair bit and gradually it comes together. In this example we add points you can have surfaces, alignments etc A few more variables available inI code would be ptnum and description. Use dumpit.lsp on existing object or code below

 

 

(Vl-load-com)
(setq e (entsel ))
(setq obj (vlax-ename->vla-object (car e)))
(vlax-dump-object obj T)

 

;; Change ProgID per Traget Civil 3D version
;; This code sample is meant for Civil 3D 2013
(setq aeccApp (vla-getinterfaceobject
(vlax-get-acad-object)
"AeccXUiLand.AeccApplication.10.0"
) ; 2013 is 10.0
)
(setq aeccDoc (vlax-get-property aeccApp "ActiveDocument"))
(setq oPoints (vlax-get-property aeccDoc "Points"))
(setq pt1 (vlax-3d-point '(10.0 10.0 1.0)))
(setq oPoint1 (vlax-invoke-method oPoints "Add" pt1))
  (vlax-put opoint1 'labelrotation 1.57) ;approx 90deg
(setq pt1 (vlax-3d-point '(20.0 10.0 2.0)))
(setq oPoint1 (vlax-invoke-method oPoints "Add" pt1))
(vlax-put opoint1 'labelrotation 3.14) ;approx 180deg
(setq pt1 (vlax-3d-point '(20.0 20.0 3.0)))
(setq oPoint1 (vlax-invoke-method oPoints "Add" pt1))
(vlax-put opoint1 'labelrotation 4.71) ;approx 270deg

Posted

Thank you BIGAL. But I have not come across equivalent of "AeccXUiLand.AeccApplication.10.0" for AutoCAD mechanical

 

How did you find this value? Is it documented somewhere?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...