Inventor General Discussion

Reply
Active Contributor
ClintWestwood
Posts: 41
Registered: ‎07-11-2013
Message 1 of 8 (340 Views)
Accepted Solution

Compress lines of code in iLogic

340 Views, 7 Replies
01-09-2014 12:00 PM

A while back I figured out how to put a few characters before and after several lines of code in iLogic to make it compress to one line or expand to its full size inside the code editor. I belive this is a fairly common VBA command, but I can't figure out how to do it again. I'm not very familiar with the guts of VBA, anyone know how to do this? I'm a neat freak and I'd really like to compress my code to make it easier to read. Thanks

Inventor 2014
HP Pavilion dv6t-6b00
Intel Core i7 2670QM
AMD Radeon HD 6490M
16gb RAM
Windows 7 64 bit
3Dconnexion SpaceExplorer
Distinguished Mentor
pcrawley
Posts: 672
Registered: ‎05-23-2002
Message 2 of 8 (331 Views)

Re: Compress lines of code in iLogic

01-09-2014 12:26 PM in reply to: ClintWestwood

Was this it?

 

Sub main()

'your code

End sub

Peter
Active Contributor
ClintWestwood
Posts: 41
Registered: ‎07-11-2013
Message 3 of 8 (325 Views)

Re: Compress lines of code in iLogic

01-09-2014 12:29 PM in reply to: pcrawley
That's it! Thank you.
Inventor 2014
HP Pavilion dv6t-6b00
Intel Core i7 2670QM
AMD Radeon HD 6490M
16gb RAM
Windows 7 64 bit
3Dconnexion SpaceExplorer
*Expert Elite*
cwhetten
Posts: 1,051
Registered: ‎09-03-2008
Message 4 of 8 (302 Views)

Re: Compress lines of code in iLogic

01-09-2014 01:01 PM in reply to: ClintWestwood

This also works:

 

'[ You can add some label text here

 

']

 

So, in case it is hard to tell what I did there, that's a single quote mark (also used to create comments), followed by an open square bracket, followed by a space.  You can then add whatever text you like, usually describing the code that is collapsed.

 

You can control where the collapsing stops by including a single quote mark followed by a closed square bracket.

 

The Sub Main() ... End Sub works, but you can only have one of those per rule.  If you have several code sections that you want to collapse, use the method I described.  It's also possible to nest with this method.

 

Cameron Whetten
Inventor 2014

Distinguished Mentor
pcrawley
Posts: 672
Registered: ‎05-23-2002
Message 5 of 8 (294 Views)

Re: Compress lines of code in iLogic

01-09-2014 01:50 PM in reply to: cwhetten

Every time I come to this discussion group, I learn something new!

Thanks!!

Peter
Active Contributor
ClintWestwood
Posts: 41
Registered: ‎07-11-2013
Message 6 of 8 (288 Views)

Re: Compress lines of code in iLogic

01-09-2014 02:01 PM in reply to: cwhetten
I have found that if I change "Main" to something else, I can use multiple sub commands throughout my rule. However, since your method has nesting capability (and doesn't require me to type as many characters) I will use it in the future. Thank you!
Inventor 2014
HP Pavilion dv6t-6b00
Intel Core i7 2670QM
AMD Radeon HD 6490M
16gb RAM
Windows 7 64 bit
3Dconnexion SpaceExplorer
Distinguished Mentor
pcrawley
Posts: 672
Registered: ‎05-23-2002
Message 7 of 8 (216 Views)

Re: Compress lines of code in iLogic

01-11-2014 05:52 PM in reply to: ClintWestwood

''' Three inverted commas (as used for a comment line) will collapse the comments to a small block.

I'm not quite sure why you'd want to, but worth a mention in your quest for tidiness.

Peter
Distinguished Mentor
pcrawley
Posts: 672
Registered: ‎05-23-2002
Message 8 of 8 (158 Views)

Re: Compress lines of code in iLogic

01-16-2014 08:07 PM in reply to: pcrawley

And here's another useful trick to add to the bag of OCD tidyness tools.

Use the ''' trick on subsequent lines of comments and the whole lot becomes collapsible:

17-01-2014 5-01-52 p-m-.png

I really like this one!

Peter

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube