AutoCAD Civil 3D Customization

AutoCAD Civil 3D Customization

Reply
Active Contributor
coffeeTwitch
Posts: 26
Registered: ‎05-19-2008
Message 1 of 28 (903 Views)

AEC Objects & LISP

903 Views, 27 Replies
04-30-2009 10:02 AM
Anyone know how to get into the AEC objects (Civil 3D & Architecture) with LISP? I am trying to get into the AEC Drawing setup info using vlax functions in lisp. The following doesn't work, but I hope it will illustrate what I am trying to do.
Any help appreciated,
tom


(defun c:getaec ( / acad_app aec_app aec_doc aec_pref temp_lu)

(setq acad_app (vlax-get-acad-object))
(setq aec_app (vlax-invoke-method acad_app 'GetInterfaceObject "AecBase.Application"))
(setq aec_doc (vlax-get-property aec_app 'AecBaseDocument))
(setq aec_pref (vlax-get-property aec_doc 'AecBaseDatabasePreferences))

(setq temp_lu (vlax-get-property aec_pref 'LinearUnit))

(print temp_lu)

)
Valued Contributor
jpkycek
Posts: 53
Registered: ‎08-17-2007
Message 2 of 28 (903 Views)

Re: AEC Objects & LISP

05-01-2009 06:26 PM in reply to: coffeeTwitch
Why are you working with lisp with civil3d?
VBA, or VB.net would work better. Edited by: jpkycek on May 2, 2009 1:42 AM
Active Contributor
coffeeTwitch
Posts: 26
Registered: ‎05-19-2008
Message 3 of 28 (903 Views)

Re: AEC Objects & LISP

05-04-2009 10:36 AM in reply to: coffeeTwitch
I'm integrating it with some previously developed LISP code that will run in Civil 3D and Architecture (trying to automate our dimstyle creation). VBA is getting left behind and I haven't taken the time to learn .net (just diving into C#). Also, I'm a little obstinate and wanted to figure out how to do this in LISP if you can.....
*Jeff Mishler
Message 4 of 28 (903 Views)

Re: AEC Objects & LISP

05-04-2009 12:54 PM in reply to: coffeeTwitch

I can do this in C3D, but have no idea how to do so in ACA.
I'm sure it's similiar, but......

 

[code]

(defun c:getaec_example (/ acad_app aec_app aec_doc
aec_pref temp_lu)
(vl-load-com)
  (setq prod
(vlax-product-key))
  (setq prodStr (strcat
"AeccXUiLand.AeccApplication"
   (cond ((vl-string-search "
href="file://\\R17.0\\">\\R17.0\\
"
prod)
         
".4.0");;2007
        
((vl-string-search "\\R17.1\\"
prod)
         
".5.0");;2008
        
((vl-string-search "\\R17.2\\"
prod)
         
".6.0");;2009
        
((vl-string-search "\\R18.0\\"
prod)
         
".7.0");;2010
         (t
""))))
        
  (if (and
(setq *acad* (vlax-get-acad-object))
    (setq C3D
(vla-getinterfaceobject *acad* prodStr))
    (setq C3Ddoc
(vla-get-activedocument C3D))
    )
   
(progn
      (setq C3Dpref (vlax-get-property C3Ddoc
'Preferences))
      (setq temp_lu
(vlax-get-property C3Dpref 'LinearUnit))
     
(print temp_lu)
      )
   
)
  (princ)
)

[/code]

 


style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
I'm
integrating it with some previously developed LISP code that will run in Civil
3D and Architecture (trying to automate our dimstyle creation). VBA is getting
left behind and I haven't taken the time to learn .net (just diving into C#).
Also, I'm a little obstinate and wanted to figure out how to do this in LISP
if you can.....
*Jeff Mishler
Message 5 of 28 (903 Views)

Re: AEC Objects & LISP

05-04-2009 01:23 PM in reply to: coffeeTwitch

and don't forget to release the C3D object before exiting,
else it will throw errors at you when closing C3D.

 

(vlax-release-object C3D)


style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>
"Jeff Mishler" <miffATsonicDOTnet> wrote in message
href="news:6176290@discussion.autodesk.com">news:6176290@discussion.autodesk.com
...


I can do this in C3D, but have no idea how to do so in ACA.
I'm sure it's similiar, but......

 

[code]

(defun c:getaec_example (/ acad_app aec_app aec_doc
aec_pref temp_lu)
(vl-load-com)
  (setq prod
(vlax-product-key))
  (setq prodStr (strcat
"AeccXUiLand.AeccApplication"
   (cond ((vl-string-search
"\\R17.0\\"
prod)
         
".4.0");;2007
        
((vl-string-search "\\R17.1\\"
prod)
         
".5.0");;2008
        
((vl-string-search "\\R17.2\\"
prod)
         
".6.0");;2009
        
((vl-string-search "\\R18.0\\"
prod)
         
".7.0");;2010
         (t
""))))
        
  (if (and
(setq *acad* (vlax-get-acad-object))
    (setq C3D
(vla-getinterfaceobject *acad* prodStr))
    (setq C3Ddoc
(vla-get-activedocument C3D))
    )
   
(progn
      (setq C3Dpref (vlax-get-property
C3Ddoc 'Preferences))
      (setq temp_lu
(vlax-get-property C3Dpref 'LinearUnit))
     
(print temp_lu)
      )
   
)
  (princ)
)

[/code]

 


style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
I'm
integrating it with some previously developed LISP code that will run in
Civil 3D and Architecture (trying to automate our dimstyle creation). VBA is
getting left behind and I haven't taken the time to learn .net (just diving
into C#). Also, I'm a little obstinate and wanted to figure out how to do
this in LISP if you can.....
Active Contributor
coffeeTwitch
Posts: 26
Registered: ‎05-19-2008
Message 6 of 28 (903 Views)

Re: AEC Objects & LISP

05-04-2009 01:27 PM in reply to: coffeeTwitch
Cool - that code runs fine for my Civil 3D - thanks. I think I can do the same with ACA using a different arx (just not the AecBase). It's funny though: ACA documents the AEC Base object model, but it seems like it's left out of Civil 3D docs. The arx is there in both programs though. It's my understanding that you are supposed to be able to get into the AecBase for general info (like the linear units settings). Have I misinterpreted this?

It feels like there is some fundamental thing I've got wrong after doing a lot of trial and all error using the
get interface object command (tried a lot of version numbers for AecBase.Application.x.x). Maybe my reference string is wrong: "AecBase.Application.x.x" ?
*Jeff Mishler
Message 7 of 28 (903 Views)

Re: AEC Objects & LISP

05-04-2009 01:39 PM in reply to: coffeeTwitch

Yeah, I tried the GetInterfaceObject for the AecBase object
too. I think it must be inherited by the LandApplication object and cannot be
directly referenced, which is why the AecBasePreferences properties can be
obtained through the Land object.

 

I have ACA 2006 installed on an old laptop at home. If I
remember tonight I'll fire it up and see what needs to be done with
it.


style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
Cool
- that code runs fine for my Civil 3D - thanks. I think I can do the same with
ACA using a different arx (just not the AecBase). It's funny though: ACA
documents the AEC Base object model, but it seems like it's left out of Civil
3D docs. The arx is there in both programs though. It's my understanding that
you are supposed to be able to get into the AecBase for general info (like the
linear units settings). Have I misinterpreted this? It feels like there is
some fundamental thing I've got wrong after doing a lot of trial and all error
using the get interface object command (tried a lot of version numbers for
AecBase.Application.x.x). Maybe my reference string is wrong:
"AecBase.Application.x.x" ?
*Peter Funk - Autodesk, Inc.
Message 8 of 28 (903 Views)

Re: AEC Objects & LISP

05-04-2009 01:42 PM in reply to: coffeeTwitch

While both programs do use AEC Base, all the Civil
Settings are stored in the Civil object model. The overlap of useful code
that will work in both Civl 3D and ACA is pretty slim.

 

LISP is not the way to work with Civil 3D (or ACA
for that matter). I would find the functions that work and are still useful
and keep them in LISP. Then port (rewrite) the functions that you need
to .NET. This will be faster and less work than keeping them in LISP and trying
to make them work with the object model. There is also a COM library for Visual
LISP that you could look at to hook into existing LISP.

 

While there are some that can write in LISP and
will argue that it is the best programming language ever invented, most of the
readers of this newsgroup and the Autodesk Developer Network support team can't
read LISP and won't be able to provide any support on it. In addition, NONE of
the Civil 3D samples or help files will ever be written in to support LISP.
.NET is the language to learn.

 

Regards,

 

Peter Funk

Civil 3D Product Manager

Autodesk, Inc.

 

 
Active Contributor
coffeeTwitch
Posts: 26
Registered: ‎05-19-2008
Message 9 of 28 (903 Views)

Re: AEC Objects & LISP

05-04-2009 02:35 PM in reply to: coffeeTwitch
Hi Peter - thanks for your reply. It looks like I'm misinterpreting how AecBase is being used. I guess it's really time to get into .net, but really, LISP (common lisp) is the best programming language ever invented! Ok, just kidding (still a neat language though), I know: right tool, for the right job. I'll rethink my approach, but for future reference, in the context of .net: If I want to grab something simple/shared like the drawing scale: would the AecBase be the appropriate object to grab (keeping in mind that I am trying to write one tool for both Civil 3D and ACA), or would you advise a check (which app am I in: C3D or ACA) and then grab the info through the specific app's object model? Or in other words: is it safe to use AecBase or is it better to use the application specific library?
thanks,
tom
Active Contributor
lelandleahy4987
Posts: 44
Registered: ‎12-30-2008
Message 10 of 28 (677 Views)

Re: AEC Objects & LISP

04-25-2012 10:51 AM in reply to: *Peter Funk - Autodesk, Inc.

Peter,

 

I agree LISP is old, but there are still many users that are more comfortable with it. I have plenty of existing LISP routines that i would like to be able to access Civil3d objects, but dont want to learn a complete new language to do it.  So being able to use visual lisp's object functions to access 3cd objects is very handy. 

 

It is funny that I was told years ago that LISP was going away and VBA is the way to go, but LISP is still avaliable with the standard deployment but you have to download and install extra stuff to get VBA working in 2012.

Leland
Civil3d 2012
Windows 7 64x (16 gigs ram)
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.