Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AEC Objects & LISP

27 REPLIES 27
Reply
Message 1 of 28
coffeeTwitch
2213 Views, 27 Replies

AEC Objects & LISP

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)

)
27 REPLIES 27
Message 2 of 28
jpkycek
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
Message 3 of 28
coffeeTwitch
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.....
Message 4 of 28
Anonymous
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.....
Message 5 of 28
Anonymous
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.....
Message 6 of 28
coffeeTwitch
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" ?
Message 7 of 28
Anonymous
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" ?
Message 8 of 28
Anonymous
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.

 

 
Message 9 of 28
coffeeTwitch
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
Message 10 of 28
lelandleahy4987
in reply to: Anonymous

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 2020
Windows 10 64x (32 gigs ram)
Message 11 of 28

VB.NET or C# are the two languages that should be used to work with Civil 3D. While the COM model is still there, it is missing many of the new features that we have added to Civil 3D, is 5 to 10 times slower than the .NET API and may be dropped when the .NET API is competed.

 

Using LISP takes the slow COM model and attaches it to the impossible syntax of LISP (yes I know LISP and I've written more commerical LISP than most people around) giving you the worst of both worlds.

 

I strongly suggest stop all LISP development (that means you too Dave G) and move to .NET. The "Express Editions" from Microsoft are free and should provide all the tools that you need.

 

Peter Funk

Autodesk, Inc.



Peter Funk
Autodesk, Inc.

Message 12 of 28
Jeff_M
in reply to: peterfunkautodesk


@peterfunkautodesk wrote:

... when the .NET API is completed.

 

Peter Funk

Autodesk, Inc.


still waiting...

Jeff_M, also a frequent Swamper
EESignature
Message 13 of 28
Veliv
in reply to: peterfunkautodesk

Me too... I have waited that from Civil 3D 2008 version.. Man Wink

LISP is the best language for testing COM based features quickly upon multiple Civil 3D versions.

No need to add references to Visual Studio 20xx.

-VV

Message 14 of 28
B.ll
in reply to: Veliv

try this:

<<<<<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
    "AecX.AecArchBaseApplication"
    (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
   ((vl-string-search
      "\\R18.2\\"
      prod
    )

    ".6.7"
   )
   ;;2012
   (t
    ""
   )
    )
  )
  )

  (if (and
 (setq *acad* (vlax-get-acad-object))
 (setq AEC
        (vla-getinterfaceobject *acad* prodStr)
 )
 (setq AECdoc
        (vla-get-activedocument AEC)
 )
      )

    (progn
      (setq AECpref (vlax-get-property
        AECdoc
        'Preferences
      )
      )
      (setq temp_lu
      (vlax-get-property AECpref 'LinearUnit)
      )

      (print temp_lu)
    )

  )
  (princ)
)

 

 

>>>>>>code>>>>>>

 

did not proof it for all versions.  just for 2012.

Message 15 of 28

Wonderful, but learn .NET for the future. LISP and COM is not the way to customize Civil 3D.

 

Peter Funk

Autodesk, Inc.



Peter Funk
Autodesk, Inc.

Message 16 of 28

I have started to learn .NET mainly to work with the rest of the world and outside of Autocad.

 

But it makes me wonder why Autodesk would add all the Visual Lisp functions to work with object models, then tell users not to use it. I personally am/was looking for ways that VLisp could read civil3d info from objects, like structures, not create them. Mainly to allow existing programs written in Lisp and working just fine be able to interact with the new objects. But by reading threads on here no matter what anyone asks or posts, Autodesk will continue to tell you to learn .NET. 

Leland
Civil3d 2020
Windows 10 64x (32 gigs ram)
Message 17 of 28

The interface that you are using in LISP is the COM API that was typically used with VBA. The COM API was designed to be easy to use compared to the C++ ObjectARX API. When it was developed it was known that by making it easy to use it gave up speed (in some cases it is 10 times slower than ObjectARX).

 

The direction of API has changed to .NET that is eaiser to use than ObjectARX but has almost the same speed (within 5%). With this change we have stopped all active development of the COM API and put all our effort behind the .NET API.

 

So I'm going to continue to say "don't use Visual LISP" for the following reasons:

1. It is slow

2. It is undocumented

3. It is untested

4. It is hard to use because ((it is LISP)(it uses a wrapper that allows LISP access to the VBA API))

5. It is missing all new object development (the new pressure pipes will not be exposed to COM)

6. It may go away in the future

7. It is very limited compared to .NET

 

Regards,

 

Peter Funk

Autodesk, Inc.



Peter Funk
Autodesk, Inc.

Message 18 of 28
Veliv
in reply to: peterfunkautodesk

Hi Peter,

I agree that we should use now and in the future .NET to develope Civil 3D applications.

I really have to give my opinion on those facts what you pointed out.

1. Lisp is slow -> thats OK

2. Lisp or ActiveX is not undocumented but there are not any lisp examples.

3. It´s as bullet proof as ActiveX can be.

4. Lisp code is hard to follow because of syntax. ActiveX interfaces are easy to use but hard to find the problem when it occurs.

5. Because Autodesk have desided to do so. It´s also easier to support one or two APIs only.

6. Or may be not. Of course in Civil 3D world Lisp is out of date.

7. All languages have their limitations even .NET but how to choose right tool to do the job. In small tasks Lisp is better because you don´t have to care about .NET references or servicepacks like .NET have to. In medium and larger Civil 3D projects it´s better to use .NET and ObjectARX languages together. There are now and in the future several ObjectARX functions which are not exposed to .NET. Example in Civil 3D Customdraw API is supported only with ObjectARX.

 

Cheers

Veli V.

Basepoint Oy

Tags (3)
Message 19 of 28
peterfunkautodesk
in reply to: Veliv

Unless I'm just making a macro function that runs a command, I don't use LISP. If I'm doing anything else, I use .NET.

 

While the .NET API isn't complete and there are still a few things that you can only do with COM you can add those into the .NET applications. On the flip side, there are features (superelevation) that you can only get in .NET that have no COM API. 

 

I wouldn't use the Custom Draw API, I would look at the Overrule API that is part of .NET because it is more powerful and can do more than just changing the graphics.

 

For #6, LISP was designed to work with DXF codes. That is where is was the most powerful. In an object world, it is the wrong tool.

 

Regards,

 

Peter Funk

Autodesk, Inc.



Peter Funk
Autodesk, Inc.

Message 20 of 28
Veliv
in reply to: peterfunkautodesk

Thank you Peter.

I think this is a good conversation to point out why we should move to .NET and ObjectARX.

-Veli V.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report