Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Specify Autocad Version (specifically use Civil 3D 2020) within LISP code to open files and change contents.

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ewano
1256 Views, 4 Replies

Specify Autocad Version (specifically use Civil 3D 2020) within LISP code to open files and change contents.

Hi All,

 

I am running into an issue where I think software versioning is creating a problem within my LISP routine.

The LISP function reads some reference tables and uses the information within them to open DWGS, update block values across multiple DWG files, save and close the files.

 

But because the files are Civil 3D DWG files, the content starts to have errors opening automatically with the default 'vanilla' AutoCAD (such as tabs / content being deleted). I know that you can specify the version of AutoCAD to be opened (AutoCAD.Application.18 etc), but to open Civil 3D you don't open it like a normal exe, but call on the  acad.exe for AutoCAD 2020 with some additional options enabled.

 

Is it possible to specify to open DWGs in Civil 3D via LISP? I am running this function from within Civil 3D 2020.

 

strcat "AutoCAD.Application.(Civil3D2020???)"

 

Screencap of code section below (cant post the full code)

ewano_0-1597194104154.png

 

 

Cheers,


Ewan



Autodesk ITF 2018-2020 / Senior Project Drafter / Technical & Computational Modelling Specialist / Dynamo Enthusiast

Labels (3)
4 REPLIES 4
Message 2 of 5
Sea-Haven
in reply to: ewano

Something like this

 

(defun openblk (blkname / adocs)
(setq acDocs (vla-get-documents (vlax-get-acad-object)))
(vla-open acDocs blkname)
(vla-activate (vla-item acdocs 1))
;(vla-put-activedocument (vlax-get-acad-object) (vla-item acdocs 1))
)
Message 3 of 5
ewano
in reply to: Sea-Haven

Thanks for the quick reply.

 

Is that forcing the LISP to be run within the current session of Civil3D? So as to not open a new instance of acad.exe to open the DWG files to be processed by the block?

Cheers,


Ewan



Autodesk ITF 2018-2020 / Senior Project Drafter / Technical & Computational Modelling Specialist / Dynamo Enthusiast

Message 4 of 5
Sea-Haven
in reply to: ewano

Try it see if it meets your needs.

Message 5 of 5
ewano
in reply to: Sea-Haven

- Code Snip from solution -

(setq exc_data nil) ;debug only
(alert " Please wait as Block attributes are extracted...")
(setq acapp (vlax-get-acad-object))
(setq adocs (vla-get-documents acapp))

 

Yep,  vlax-get-acad-object was the key 🙂

Thanks for your assistance @Sea-Haven , really appreciated.

Cheers,


Ewan



Autodesk ITF 2018-2020 / Senior Project Drafter / Technical & Computational Modelling Specialist / Dynamo Enthusiast

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report