TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Coder on April 03, 2021, 05:52:05 AM

Title: AutoLISP with Microstation
Post by: Coder on April 03, 2021, 05:52:05 AM
Hello everyone.

The company that I work for will start using MicroStation program and I might be one of the others who would use this software.

I've read a few threads on the internet is that MicroStation does not run or use AutoLISP routines but I am still can't confirm this.

Is there a way to run Lisp routine in MicroStation or any work around this big obstacle?

Thank you in advance.
Title: Re: AutoLISP with Microstation
Post by: Grrr1337 on April 03, 2021, 09:09:46 AM
Never used Microstation, but at first glance looks like it supports VBA (https://egeomate.com/developing-vba-applications-with-microstation/) as a development language, which is something.
Title: Re: AutoLISP with Microstation
Post by: Coder on April 03, 2021, 09:14:08 AM
Thank you for your reply.

I need to be able to use AutoLISP or convert Lisp routines into any other language that can be used in MicroStation.
I don't know anything about VBA.
Title: Re: AutoLISP with Microstation
Post by: Grrr1337 on April 03, 2021, 01:56:39 PM
I need to be able to use AutoLISP or convert Lisp routines into any other language that can be used in MicroStation.

I don't think you would be able to use AutoLISP directly for MicroStation, so you'll have to 'convert' them into other language which is supported by MS.
Conversion is not the most accurate verb, rather its to 'translate' the algorithm of the LISP routine to be used in another (similar) API.


I don't know anything about VBA.

Its the first thing I check, which would mean that it supports COM (https://communities.bentley.com/products/programming/microstation_programming/w/wiki/48725/object-model), so you could use LISP from ACAD to instantise MS object and create new Document and manipulate stuff via properties'n'methods - sample pseudocode:
Code: [Select]
; NOTE: its a sample pseudocode, it should not work if you copy-paste
(setq MSapp (vlax-get-or-create-object "Bentley.Interop.MicroStationDGN.Application"))
(vlax-invoke-method MSapp 'Show :vlax-true)
(setq MSdoc (vlax-invoke-method MSapp 'AddDocument "Sample document"))

But this LISP'ing approach is only "ODBX-like", meaning that it would be only suitable for automating tasks for like 50 MS projects in a row,
and not for creating new custom commands for to be invoked by the user while working in MS.

MicroStation Development Languages (http://www.la-solutions.co.uk/content/V8/MicroStationDevelopmentLanguages.htm)
Looks like they support C# aswell.

Title: Re: AutoLISP with Microstation
Post by: Coder on April 03, 2021, 03:06:36 PM
Thank you for your kind explanation, that helps a lot.
Title: Re: AutoLISP with Microstation
Post by: BIGAL on April 03, 2021, 07:22:09 PM
Years ago looked at Microstation and using MDL, its a C programming language structure so can see why a lot of people never write anything.

I would go down the VBA way if your use to VL commands.

I had a lisp2c converter years ago it sort of fell off the planet may still be out there. The issue is it may be even 16bit code so need a old pc to run it on.

re 2001 forum comment

A few years back when AD introduced "C" and ARX there were two product
that were put on the market to convert lisp to "C"

One from Slovinia L2C (I think) and ours drc_yak. from drcauto.com
the Guys that brought you LT toolkit (+lisp for LT). Gary D'arcy
Title: Re: AutoLISP with Microstation
Post by: wizman on April 04, 2021, 05:04:37 AM
Back in V8i days, the commonly used lisp routines are built-in commands already in Microstation, you just have to find the tool.  You may start with recording macros since it is the easiest way to script and as well as using a series of key-ins is the way to go to automate tasks.  MDL's, i believe, are the more advanced programming packages.  But I'm not sure if these are all available in the newer versions of Microstation.
Title: Re: AutoLISP with Microstation
Post by: Coder on April 04, 2021, 07:16:53 AM
Back in V8i days, the commonly used lisp routines are built-in commands already in Microstation, you just have to find the tool.  You may start with recording macros since it is the easiest way to script and as well as using a series of key-ins is the way to go to automate tasks.  MDL's, i believe, are the more advanced programming packages.  But I'm not sure if these are all available in the newer versions of Microstation.

Thank you for your kind reply.

Are you indicating to .scr file when you said 'the easiest way to script' ?

Even macros and scripts are not enough to do coding
Title: Re: AutoLISP with Microstation
Post by: wizman on April 04, 2021, 07:24:31 AM
Back in V8i days, the commonly used lisp routines are built-in commands already in Microstation, you just have to find the tool.  You may start with recording macros since it is the easiest way to script and as well as using a series of key-ins is the way to go to automate tasks.  MDL's, i believe, are the more advanced programming packages.  But I'm not sure if these are all available in the newer versions of Microstation.

Thank you for your kind reply.

Are you indicating to .scr file when you said 'the easiest way to script' ?

Even macros and scripts are not enough to do coding

From I my recollection,  Scr files equivalent can be .txt file in MS.  Recorded macros are in .Mvba format. Then you can further dive into vba once you get the basics commands coming from recorded macros.
Title: Re: AutoLISP with Microstation
Post by: Coder on April 04, 2021, 07:34:47 AM
Will it be difficult to run the lisp routine in AutoCAD then convert the drawing into MicroStation and vice versa ?
Title: Re: AutoLISP with Microstation
Post by: wizman on April 04, 2021, 11:34:27 AM
Will it be difficult to run the lisp routine in AutoCAD then convert the drawing into MicroStation and vice versa ?

Doable also but beware also that there are alot of mappings involved i.e. layers on/off, linetype, etc.

That can be your initial workflow while you are getting used to a totally different way of doing CAD.

But once you are familiar with MS, you don't want to switch back and forth between two programs.

There is a steep learning curve since it is not as user friendly but eventually you will find MS as a powerful & quick as AutoCAD can be.

One notable workflow difference between the two is that MS borders (titleblocks) are in modelspace. usually rotated, and usually not fixed at 0,0 origin.  So that is one thing you have to consider when you are switching between AutoCAD and Microstation.
Title: Re: AutoLISP with Microstation
Post by: Coder on April 04, 2021, 12:10:52 PM
Thank you so much for your important inputs.

Sorry to bother you again and hopefully this should be my last question.

I am planning to convert the drawings to CAD from MS to run my Lisp routines when needed then convert it back to MS, so will it be possible to lose objects on conversion between MS & CAD ?
Title: Re: AutoLISP with Microstation
Post by: wizman on April 04, 2021, 12:40:00 PM
Sure thing!

V8i vs AutoCAD 20xx is very much possible to lose entities since at the time of developing MS, the newer AutoCAD objects are not yet recognized by MS like fields, multiview-blocks, dynamic blocks, tables, multi-leaders, wipeouts within blocks and others.
I recall draworders of wipeouts within blocks get messed up from MS to ACAD.

Be aware also that the first few linetypes in MS are specific only for MS and not available in AutoCAD.

Connect edition should have recognized these newer objects. Just make sure you have the proper enablers. 

MS is at first slow since it is tool based but the trick is to assign them as function keys.

My custom keyboard shortcuts in AutoCAD are numerical. I had them assigned to the Function key equivalents so there is no effort in switching between the two software. 
Title: Re: AutoLISP with Microstation
Post by: Coder on April 04, 2021, 01:59:12 PM
Be aware also that the first few linetypes in MS are specific only for MS and not available in AutoCAD.

I have not been involved into MS yet but I used to receive drawings converted from MS to AutoCAD and the Linetypes still available in AutoCAD and usually there used to be many when I drop down the Linetype control list.

Connect edition should have recognized these newer objects. Just make sure you have the proper enablers. 

Yes, this supports my above explanation in a way or another.

MS is at first slow since it is tool based but the trick is to assign them as function keys.

My custom keyboard shortcuts in AutoCAD are numerical. I had them assigned to the Function key equivalents so there is no effort in switching between the two software. 

Sorry I did not get your point here.

Thank you.
Title: Re: AutoLISP with Microstation
Post by: Coder on April 04, 2021, 02:34:23 PM
First Step?> ...................

Can you please leave this thread academic and stop messing up with threads in this forum including this one with your useless replies ?

Title: Re: AutoLISP with Microstation
Post by: wizman on April 04, 2021, 03:33:23 PM
Please see the two links below regarding the linestyles (linetypes).
https://docs.bentley.com/LiveContent/web/MicroStation%20Help-v14/en/GUID-B4A2D2E6-0F9C-E61A-3953-339729FE67E4.html
https://communities.bentley.com/products/microstation/w/microstation__wiki/15269/saving-a-dgn-to-dwg-the-line-styles-are-not-displaying-correctly


Quote
MS is at first slow since it is tool based but the trick is to assign them as function keys.

My custom keyboard shortcuts in AutoCAD are numerical. I had them assigned to the Function key equivalents so there is no effort in switching between the two software.

Just an advice if you are used to having shortcut keys in AutoCAD.  In Microstation, you assign the shortcut keys to function keys F1 to F12.
Title: Re: AutoLISP with Microstation
Post by: Coder on April 04, 2021, 04:03:36 PM
Many thanks for your kind and important replies, I can't thank you enough.

Have a great day.
Title: Re: AutoLISP with Microstation
Post by: BIGAL on April 04, 2021, 06:34:07 PM
The macro looks like the way to go if it writes VBA then lots can help it should be very similar to Autocad VBA.

Open MS and do a couple of macro's draw a
line 0,0 10,10
Circle 10,10 rad 20
Pline in Ms

Post them here would like to have a look.
Title: Re: AutoLISP with Microstation
Post by: Coder on April 04, 2021, 06:40:26 PM
The routines that I have for my AutoCAD are not a sequence of commands like scripts so there could be lots of vl-* and vlax-* functions and macros don't help at all in such circumstances.
Title: Re: AutoLISP with Microstation
Post by: wizman on April 04, 2021, 08:30:58 PM
Many thanks for your kind and important replies, I can't thank you enough.

Have a great day.

I'm pretty sure you'll be up and running in no time. 
http://www.la-solutions.co.uk/content/CONNECT/MVBA/MVBA-Tips.htm

Credits to site owner.
Title: Re: AutoLISP with Microstation
Post by: Coder on April 05, 2021, 04:47:02 AM
I used to read that VBA language has been left behind and users going to .NET languages and also other than VB to any of C languages like C++, C# ... etc, so Am I going to be forced to learn VBA now to be able to code in MS? Ohh that is overwhelming indeed.

Thank you.
Title: Re: AutoLISP with Microstation
Post by: wizman on April 05, 2021, 06:07:45 AM
I used to read that VBA language has been left behind and users going to .NET languages and also other than VB to any of C languages like C++, C# ... etc, so Am I going to be forced to learn VBA now to be able to code in MS? Ohh that is overwhelming indeed.

Thank you.

First is to learn the software first in 2D and 3D before diving into programming.  Familiarize with the program first.  Another to note again is that one dgn file can contain multiple modelspaces. I believe it has a lot more tools than AutoCAD.  That is why most of the needed automations are built-in already. Then  go for  scripting using series of key-ins in a notepad and recorded macros for automations. VBA is the easiest and is just the first step if you are coming from vba programming for AutoCAD and Excel.

If you know already the advanced languages, no need for vba.  More discussions and resources can be found in Bentley Communities and Bentley Learn.
Title: Re: AutoLISP with Microstation
Post by: Coder on April 05, 2021, 07:08:02 AM
The problem with Scripts and recorded macros is that I need to stick with commands and that's not what I want because I have some AutoLISP custom programs that don't use commands in them at all, so in this case I won't be able to load nor to run them on MS program.

I have not coded in VBA before and was about to start learning it a few years back but I have read lots of recommendations all over forums is that VBA is not going to continue and C languages would replace it in the next few coming years, besides that Autodesk disconnected VBA editor ( API ) from AutoCAD and users need to download it individually if they want to code in VBA with AutoCAD and that was another reason for me to stop thinking of VBA.

I am open to new ideas and for more discussions.

Title: Re: AutoLISP with Microstation
Post by: BIGAL on April 05, 2021, 08:38:55 PM
Coder VL often refers to the VBA help so it is very similar syntax

Like Vla-get-layer is object.layer loops are more friendly you use arrays for lists that is pt(0) is x pt(1) is y pt(2) is z

I only dabble at the edges but there is heaps of examples out there when you google. Using VBA in excel means 1 language.

Post a lisp if some one has time will convert to VBA. On Autodesk Help lots of examples have VBA and Lisp code so can see the same result.

Just need some of the way MS expects object names etc.

A google
MicroStation VBA documentation ..\Bentley\MicroStation\MicroStationVBA.chm

This document is delivered with MicroStation. MicroStation VBA, the MicroStation V8 implementation of the Microsoft Visual Basic for Applications engine, one of the most popular programming environments in the world, provides MicroStation users (as well as developers) with a large number of capabilities -- from easy customization to tight integration with other Windows applications. In addition to identifying all the enums, objects, events, methods, properties, and types available, the MicroStation VBA documentation also includes a number of examples as well as a general overview covering the following:
Title: Re: AutoLISP with Microstation
Post by: Coder on April 06, 2021, 07:12:35 AM
Thank you.
I am waiting for the moment to start with MS then after that I can decide which way to take.
Title: Re: AutoLISP with Microstation
Post by: JohnK on April 06, 2021, 11:24:53 AM
I used MicroStation for a few years and, it was very difficult to use/transition to. AutoCAD and MicroStation do a lot of things very differently.

Programming: the languages you choose depends on the platforms API and what you want to do or your level of programming knowledge. AutoCAD has an AutoLisp interpreter built in whereas MicroStation does not (thus, no AutoLisp in MicroStation).

C is a low level language so if you know C you can usually use/learn a higher level language like Lisp, VB(A), etc fairly easily.

Code generators/converters: I'm sorry but converting one language to another just doesn't work that way. Languages have different methods and uses for basic elements and there isn't a direct comparison.
Title: Re: AutoLISP with Microstation
Post by: Coder on April 06, 2021, 12:02:27 PM
Thank you John for your reply, that means a lot to me.
Title: Re: AutoLISP with Microstation
Post by: jvillarreal on April 06, 2021, 01:51:03 PM
I have about 12 years experience with AutoCAD/Civil 3D and Microstation/Geopak; most recently OpenRoads Connect Edition.
If you've become accustomed to the command line in AutoCAD, there are a few options in Microstation to ease the transition.

-Customization of function keys (as mentioned)
-Position Mapping (Microstation's built in hotkeys)

If using any version before the "Connect Edition"
-Accudraw Shortcuts (These are limited to two key combinations, but can be mapped to any key-in or a script of key-ins)

-There should also be available utility delivered with Microstation called the Alias Manager (attached if not), where you can create shortcuts mapped to key-ins or scripts.
More info here:
https://communities.bentley.com/products/microstation/w/askinga/400/understanding-the-alias-manager

If you decide to use either the accudraw shortcuts or alias manager, you'll find it particularly helpful to use a customizable mouse for launching the alias manager
mdl or setting focus to the accudraw shortcut window.


If using Connect Edition:
It includes a built-in tool for creating shortcut key-ins.
It also includes a search bar on the top right that will help you launch a tool using keywords, which is extremely useful for beginners.
Title: Re: AutoLISP with Microstation
Post by: BIGAL on April 06, 2021, 08:04:58 PM
To John is this backwards ?

"C is a low level language so if you know C you can usually use/learn a higher level language like Lisp, VB(A), etc fairly easily."

Like lisp 4 lines of code C is like 10 lines of code.

I still have the lisp2c converter but needs to run on like my 1st laptop its maybe 16 bit if any ideas how to run in windows 10 happy to try on code.

Had a quick look and one method the option NTVDM is not available.
Title: Re: AutoLISP with Microstation
Post by: Coder on April 07, 2021, 03:38:16 AM
Thank you jvillarreal for your inputs, that is surely very important to know.
Title: Re: AutoLISP with Microstation
Post by: Lee Mac on April 07, 2021, 03:42:50 PM
To John is this backwards ?

"C is a low level language so if you know C you can usually use/learn a higher level language like Lisp, VB(A), etc fairly easily."

Like lisp 4 lines of code C is like 10 lines of code.

Backwards in what sense?

Languages such as LISP/VBA are considered high level because many operations are abstracted (https://en.wikipedia.org/wiki/Abstraction_(computer_science)) away and instead performed by the interpreter/compiler; consequently, programs may be written far more succinctly using relatively readable 'natural' language rather than machine code, generally at the sacrifice of power and performance; whereas low level languages (such as Assembly) are 'closer to the metal', and consequently written in language more readable to a machine than a human, with far fewer operations abstracted, consequently requiring significantly more code to perform the same operation as a high-level language (in which the equivalent machine code is implemented through the design of the language itself, rather than the programmer).
Title: Re: AutoLISP with Microstation
Post by: d2010 on April 10, 2021, 04:53:38 AM
Coder VL often refers to the VBA help so it is very similar syntax
Like Vla-get-layer is object.layer loops are more friendly you use arrays for lists that is pt(0) is x pt(1) is y pt(2) is z
Post a lisp if some one has time will convert to VBA. On Autodesk Help lots of examples have VBA and Lisp code so can see the same result.

I  hack from  Autodesk.com
"While there is no established release in which VBA will no longer be supported in AutoCAD"
.
Code: [Select]
While there is no established release in which VBA will no longer be supported in AutoCAD,
we recommend that you begin migrating your existing VBA projects to ensure that you are
ready when VBA support is dropped. We recommend that you develop any new applications
with Microsoft Visual Studio and the AutoCAD .NET API, AutoLISP, or C++ and ObjectARX.
Title: Re: AutoLISP with Microstation
Post by: BIGAL on April 10, 2021, 09:05:28 PM
There certainly is public announcements about Autodesk dropping VBA but its about 5 years old now and we still see VBA being supported, maybe Bill had a chat with Autodesk, think Word and Excel are they going to drop VBA ?

The question is will Microstation support VBA in future after all that is what this post is about.

2022
https://knowledge.autodesk.com/support/autocad/downloads/caas/downloads/content/download-the-microsoft-vba-module-for-autocad.html
Title: Re: AutoLISP with Microstation
Post by: JohnK on April 12, 2021, 12:42:18 PM
I doubt microsoft will remove VBA from office products (or autodesk from autocad) but overall VB is sort of dead; from what I heard (not that I care all that much so it was only a brief read) VB will not be developed further in future .NET versions. -i.e. so it sits where AutoLisp currently sits and has sat for years, and years; in limbo. No real progress on the language.
Title: Re: AutoLISP with Microstation
Post by: domenicomaria on April 13, 2021, 01:25:28 PM
Quote
. . . so it sits where AutoLisp currently sits and has sat for years, and years;
in limbo.
No real progress on the language.

Maybe the answer could be BricsCAD, BLADE and OpenDCL.
Title: Re: AutoLISP with Microstation
Post by: JohnK on April 13, 2021, 07:30:09 PM
Microstation will not adopt AutoLisp (or any variant). Besides there are far more powerful embedded languages--like lua--they could adopt (but they won't) for far less overhead. Microstation, Autodesk, Microsoft, etc. are--and have been for years now--shifting towards compiled languages like C# and C++.

BricsCAD adopted lisp because it is what the current CAD user base uses.

Quote
. . . so it sits where AutoLisp currently sits and has sat for years, and years;
in limbo.
No real progress on the language.

Maybe the answer could be BricsCAD, BLADE and OpenDCL.

Title: Re: AutoLISP with Microstation
Post by: domenicomaria on April 14, 2021, 12:09:20 PM
Quote
Maybe the answer could be BricsCAD, BLADE and OpenDCL.

I want mean that BricsCAD, BLADE and OpenDCL
could be a solution for Visual(?)Lispers
because Blade and the Lisp of BricsCAD and OpenDCL
are slowly growing . . .

And they haven't stopped for many years like Acad's Lisp.

This has nothing to do with MicroStation, of course.

Title: Re: AutoLISP with Microstation
Post by: JohnK on April 14, 2021, 12:55:07 PM
Oh, of course.
Quote
Maybe the answer could be BricsCAD, BLADE and OpenDCL.

I want mean that BricsCAD, BLADE and OpenDCL
could be a solution for Visual(?)Lispers
because Blade and the Lisp of BricsCAD and OpenDCL
are slowly growing . . .

And they haven't stopped for many years like Acad's Lisp.

This has nothing to do with MicroStation, of course.
Title: Re: AutoLISP with Microstation
Post by: d2010 on April 14, 2021, 03:00:38 PM
Perhaps, we need increase the speed of LISP with dot.Net.
We need research, how to increase the speed of VLISP inside Bri?Cad or Aut?Cad.
How to execute VLISP -function/s totally  isInside C#?
 :embarrassed:
Oh, of course.
Quote
Maybe the answer could be BricsCAD, BLADE and OpenDCL.
I want mean that BricsCAD, BLADE and OpenDCL
could be a solution for Visual(?)Lispers
because Blade and the Lisp of BricsCAD and OpenDCL
are slowly growing . . .
And they haven't stopped for many years like Acad's Lisp.
This has nothing to do with MicroStation, of course.

Title: Re: AutoLISP with Microstation
Post by: domenicomaria on April 15, 2021, 09:41:19 AM
Quote
How to execute VLISP -function/s totally  isInside C#?

Maybe it is better to execute C# functions inside VLISP !

This is the work that can be done !

C# library functions for VLISP.

Title: Re: AutoLISP with Microstation
Post by: domenicomaria on April 16, 2021, 12:29:44 AM
it would be very interesting if
there was a blog where people collaborate
to create (open source) functions written in C#,
for VLISP

This could be the best evolution for VLISP at the moment.
Title: Re: AutoLISP with Microstation
Post by: BIGAL on April 16, 2021, 03:46:10 AM
Dont you mean just replace VL commands with c#

There is already people out there offering .net library routines. I tried out some of the excel routines and work well.

(http://)
Title: Re: AutoLISP with Microstation
Post by: domenicomaria on April 16, 2021, 05:57:10 AM
Quote
Dont you mean just replace VL commands with c#
I mean anything that can implement the VLISP language. . .

(in the past at the time of AutoLISP with a friend of mine
we wrote a small library of functions in ANSI C for ACAD 12,
when there was the ADS (Advanced Development System) . . .)

I mean something like this.
But it is important that it is OPEN SOURCE.

There are many Open Source software . . .

We can at least create an open source VLISP implementation . . .

Title: Re: AutoLISP with Microstation
Post by: Jeremy Dunn on April 18, 2021, 07:17:28 PM
Dont you mean just replace VL commands with c#

There is already people out there offering .net library routines. I tried out some of the excel routines and work well.

(http://)

Tried loading these functions with no luck. Unblocked the file and have it in the Support directory. No function error when I type (alx-help)
Title: Re: AutoLISP with Microstation
Post by: BIGAL on April 18, 2021, 10:36:13 PM
i took me a couple of goes to unblock the file I think i had to do it to the one that was original download then copied to support directory.
Title: Re: AutoLISP with Microstation
Post by: JohnK on June 09, 2021, 04:06:54 PM
Can you test, the BabaCad2020 can execute AutoLisp?>
...<snip>

I think Coder said his company will be using Microstation (I do not think they have a choice about the cad platform their company will be using). I believe the question about using Lisp in Microstation was to attempt to keep some of the many custom solutions developed to help speed along the drafting process but as I pointed out before, the user experiences are different so most methods of speeding up drafting tasks in one platform will just not apply in the other platform because of how things are done differently in each.

But thanks for the link; someone reading this thread later may have the option to try other CAD platforms.
Title: Re: AutoLISP with Microstation
Post by: BIGAL on June 09, 2021, 08:55:43 PM
As I said before Lisp2c was available to convert lisp to C. There is another as well maybe still out there, the second author had a Lisp for LT but Autodesk did not like that and legally shut it down. I still have lisp2c.exe it but need a old pc to run it on.

So a open source lisp to C could be a good idea.
Title: Re: AutoLISP with Microstation
Post by: JohnK on June 14, 2021, 03:45:18 PM
I looked into Lisp2C and it appears to have been just another interpreter (which essentially means it was a "wrapper" that was used within AutoCAD). I'd have to study more but it sounded like a bit of a pain to use.

Converting one language to another is very difficult because of all the little language nuances -i.e. AutoLisp is very sloppy. I made one attempt to generate AutoLisp from a generic/custom language I made up and it was very difficult (and I was beat up with "how about this/that situation?" problems). However we could start to build a an interpreter and mock up tools like a "cross-reference" (counts variables and whatnot) to see how much interest we gain or how useful something like that would be.
Title: Re: AutoLISP with Microstation
Post by: BIGAL on June 14, 2021, 10:35:30 PM
No lisp2c.exe program wrote C code it was developed when Autocad 1st introduced "C" coding yes I am that old its in my R12 1992 Customisation manual with ADS examples. Has link to Author etc.


Note is probably 16bit