Loading
Hey! This thing is still a Work in Progress. Files, instructions, and other stuff might change!
Justblair

OpenSCAD/Notepad++ Language File (including useage guide)

by Justblair Jan 3, 2012
Download All Files

Please Login to Comment

Thank you for the time you invested in making this notepad++ language definition. I prefer to use notepad++ for editing my text files and this was a great addition to OpenSCAD. I used it today for the first time (it was my first time using OpenSCAD, as well) and it worked very well.

Thanks again.

Thanks,

I have a couple questions on the autocomplete section.

It looks like I can just fill out the openscad.xml to have more popups for example using the cube example for cylinder
changed to the following :

KeyWord name="cylinder" func="yes"
Overload retVal="Parameters for"
Param name="h = height" /
Param name="r1 - BottomRadius" /
Param name="r2 = TopRadius" /
Param name="center=true/false" /

(it wouldn't let be copy and paste the code with <> for some reason..)

I can see how I can add these to the rest of the primitives to create my cheatsheet but I was wondering if you can call up cylinder in a list say by typing "cyl" select "cylinder" and it would input "cylinder(h = height, r1 = BottomRadius, r2 = TopRadius, center = true/false);" instead of just the name attribute? I like the popup tool tip style but I still have to click out of the "( )" and type the ";" would be sweet to just have it all there when I select it from the list....

any help appreciate it or maybe someone has completed the openscad.xml file more for the rest of the shapes, etc.. ?

Thank you for your time,
-Aaron

Thanks very much for the language definition. I've been using it for a couple of days now.

To add support for listing OpenSCAD modules in the Notepad++ function list you can make the following changes to functionList.xml:

  1. In the <associationMap> block add:
    <association userDefinedLangName="openscad" id="scad_module"></association>
    n.b. If you used a different language name than "openscad" when you imported the language definition, use that name here instead.

  2. In the parsers block add:
    <parser id="scad_module" displayName="scad" commentExpr="((/*.?*)/|(//.?$))">
    <function
    mainExpr="((^|[\s]+|[;}.])([A-Za-z][\w].)[A-Za-z][\w][\s][=:]|^|[\s;}]+)[\s]module([\s]+[A-Za-z]?[\w]([^)(])|([^)(]))[\n\s]{"
    displayMode="$functionName">
    <functionName>
    <nameExpr expr="[A-Za-z][\w]
    [\s][=:]|[A-Za-z]?[\w][\s]("></nameExpr>
    <nameExpr expr="[A-Za-z]?[\w]
    "></nameExpr>
    </functionName>
    </function>
    </parser>

Sorry, I don't know why the code was missing.
I added the following to functionsList.xml i hope it stays this time :

Hi,
I´m using your awesome Notepad++ configuration files for OpenSCAD. However those files do not allow for listing modules and functions in the "function list" window. It seems from the manual that I have to create a new parser in functionList.xml. I tried to create a new parser for this language from the existing ones without success. I’m not a fluent programmer. I only need to detect the words ‘module’ and ‘function’.

I added the following to functionsList.xml :

Maybe there are some errors in this code, I don’t know. Can you help? Thanks a lot. Kind regards.

Thanks! This is awesome. It is so much faster. I always love Notepad++ and am just learning OpenSCAD.

Wow with this using Openscad is so much easier! TKX!!!

Hi!
I got notepad++ 6.6.8
i got openscad.xml
In notepad++ / language menu / define your language / Import
I get "Fail to import" after choosing openscad.xml
Windows 7 Pro, notepad++ NOT in a protected system area.
Thank you for your help!

You are awesome. This is sooooo much better than using the built-in Openscad text editor. Thanks!

This somewhat worked for me, but 'Save' is grayed out on Notepad++ now. Any ideas?

'Save' will be greyed out if there are no pending changes to be saved, try altering the file and see if it becomes enabled.

This is great. Has anyone done the same thing for any Mac code editor?

Actually the connection between Notepad++ and Openscad can be even more automatic than you describe. You need to add a "Run" shortcut to Notepad++ which automatically invokes Openscad. To do that requires:

1.Run->Run... add "C:\Program Files(x86)\OpenSCAD\openscad.exe" "$(FULL_CURRENT_PATH)"

(or whatever your path is) to the dialog box.

  1. Save...

  2. Name: openscad (actually anything you want to call it)

Assign a key short cut ( I use ALT-O) OK

Exit Notepad++; restart it and you should find openscad under the run menu.

You can now create a file and have Notepad++ automatically start Openscad using that file. If you have set Design-> "Automatic Reload and compile" and View->"Hide Editor" in Openscad you will regenerate the model every time you do a Save (Cntrl-S) in Notepad++

I love the automation here. A batch file can also run both Openscad and Notepad++. Use a text editor to create a .bat file (I called mine scadfile.bat) with the following contents: (modify it to reflect the locations of your installed programs)

start "" "D:\Programs\npp.5.8.7\unicode\notepad++.exe" %1
start "" "D:\Programs\openscad-2011.12.30\openscad.exe" %1

Then right-click on a .scad file and go to "Open With" -> "Choose default program". Browse to the batch file you just created then click OK. Now OpenScad and Notepad++ will both open whenever you double-click on your .scad file.

I see what you are doing there. But for some reason I am unable to follow your instructions. Everything seems ok, but when I click the menu item or shortcut nothing happens.

I had some trouble getting this just right. You can check the shortcut by going into Users\<yourname>\AppData\Roaming\Notepad++\shortcuts.xml and validating that the line with the shortcut is:

<command alt="yes" ctrl="no" key="79" name="openscad" shift="no">"C:\Program Files (x86)\OpenSCAD\openscad.exe" "$(FULL_CURRENT_PATH)"

If it is not exactly like this, then edit shortcuts.xml (not with Notepad++) and change the line to match.</yourname>

I cant get this bit to work either. I am in C:Users\<name> but see no \AppData. I am in Win7 64bit.</name>

The quotes should be ampersandquot

You rock, I hated the amount of TABing I had to do with the built in text editor. This is perfect!

This seems like a great thing and a huge time-saver! Only problem is, I can't seem to install it? I'm running Notepad++ 5.5.1 on a 64 bit Windows notebook. When I open the User Defined Dialog, I don't see any way to do an "Import". I tried to do an Import style themes from the Settings menu, but it didn't do anything.

Any suggestions? What have I done wrong?

Thanks.

I just downloaded Notepad++ v6.2.2 and apparently they moved where to do the import.   I found it under  Language>Define Your Language...>Import  to get it to show up, you must import it, then pick it from the drop down list at the top of the user defined window where it says user define language.  then click on Save As and type in OpenScad.. now there will be an OpenScad entry at the bottom of the language pulldown.   

By the way, I really like having my editor in a separate window, makes it so much nicer on dual monitors!!

Someone give this guy a medal.

Great work by the way, huge time saver.

To get notepad++ to open scad files with the right highlighting, all you have to do is add set the ext="scad" in the second line of the openscad.xml
&
lt;userlang name="openscad" ext="scad"
&
gt;

That will do it automatically for anyone who imports the xml new. If you've already imported it and dont want to do it agian, you can just go to View-
&
gt;User Defined Dialog... And in the pop up, select "openscad" from the "user language" dropdown, and set the "Ext:" input box to "scad"

Thanks for that CrazyJaw. I have updated the xml file with your suggested information. It's only a little change, but it does make the whole experiance so much slicker :)

I installed it but the new language did not appear. I quit notepad++ and started it again but now it crashes and will not start. :'(

I can't find any files modified today apart from the crash dump and I can't find anything in the registry. How do I get rid of it?

Happened to me as well. I just re-installed npp on top of the old install, and it works nicely. You might want to put the xml files in the npp directory as well if you didn't do that.

Thanks for the nice guide and language definition, Justblair. And the autoComplete is sweet as well.

Sorry to hear that Nophead. Which bit did you install? Both files or just the first...

The file that gets altered when you import the language file (first stage) is held in

C:\Users\
&
lt;your user name
&
gt;\AppData\Roaming\Notepad++\userDefineLang.xml

If you have a look at it you will see all the data there in xml format

I installed just the first.

I got it running by installing notepad++ again. It now has the openscad language option which seems to work except the text background is black but the screen where there is no next is white. I.e. white space is white!

I changed the global default background to black and it works now, thanks.

It doesn't automatically recognise scad files from the extension. I have to tell it each time I open one. Is that right?

Considering that there is this issue that I just had to change. You should probably set the background color to black in the xml file. Also the line highlighting color should be set to a darker grey, considering the black background and the white text.

Yep. I haven't explored how to get that bit working yet. If anyone can suggest how i will add it to the guide.

Awesome, thanks. The syntax highlighting and auto-completion are a huge improvement on the default editor.

Glad you like it. I don't think I could go back now, even after just a few days using the Notepad++ features I consider it indispensable.

Excellent. and great timing. I was just getting fed up with the OpenSCAD editor.

Thanks!

Glad you find it useful Ben. Any feedback about how well or badly the language files are for you will be welcome.

I have not had a chance to play too much with the auto-complete tonight, but I think that it speeds up my coding.

The other thing to remember using notepad++ is the CTRL+Enter keyboard combo which gives you a list of words you have used recently. Very handy for autofilling in variable names.

Everyone thinks openscad is missing block commenting/tabbing but it's not true:

Block comment: Ctrl+d (add shift to un-comment)

Block tab: Ctrl+u (add shift to un-tab)

These shortcuts can be found in the menu.

Thanks Polymaker.. I had been trying to use the tab key... I will amend the instructions accordingly