Posting a new macro

Need help, or want to share a macro? Post here!
aleph0
Posts: 28
Joined: Fri Jan 29, 2016 10:04 am
Location: Cambridge, England
Contact:

Posting a new macro

Postby aleph0 » Fri Jan 29, 2016 10:10 am

I have a macro that I would like to publish because I think it might be useful to other FreeCAD users. The macro displays a cross-section of the visible objects, which can be dynamically moved through the scene with a slider bar. How do I publish a macro?
User avatar
yorik
Site Admin
Posts: 12065
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels, Belgium
Contact:

Re: Posting a new macro

Postby yorik » Fri Jan 29, 2016 2:51 pm

cool, that might be very useful!
The best way is to add an entry on the Macros recipes page. If it's okay for you to do so (instructions are given on the page), tell me and I give you edit permission to the wiki...
User avatar
bernd
Posts: 10976
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Posting a new macro

Postby bernd » Sat Jan 30, 2016 7:26 am

aleph0 wrote:I have a macro that I would like to publish because I think it might be useful to other FreeCAD users. The macro displays a cross-section of the visible objects, which can be dynamically moved through the scene with a slider bar. How do I publish a macro?
wow cool, moving a section with slider bar is what I have been missing in the clipping box for years. You could also post the code in the forum here. put the code in code tags. But the better way is at the wiki like proposed by yorik.
aleph0
Posts: 28
Joined: Fri Jan 29, 2016 10:04 am
Location: Cambridge, England
Contact:

Re: Posting a new macro

Postby aleph0 » Sat Jan 30, 2016 6:28 pm

Yes, please, if you give me edit permission I'll post it. However thee seems to be a problem with registering on the Wiki (which In presume I have to do first so that you can give me permission). If I click on a Register button, I get taken to the registration page for "MediaWiki", but the resulting registration doesn't allow me to log in on the FreeCAD wiki.
User avatar
sgrogan
Posts: 6166
Joined: Wed Oct 22, 2014 5:02 pm

Re: Posting a new macro

Postby sgrogan » Sat Jan 30, 2016 7:22 pm

aleph0 wrote:Yes, please, if you give me edit permission I'll post it. However thee seems to be a problem with registering on the Wiki (which In presume I have to do first so that you can give me permission). If I click on a Register button, I get taken to the registration page for "MediaWiki", but the resulting registration doesn't allow me to log in on the FreeCAD wiki.
I think you now can contribute to the "MediaWiki" but not the "FreeCAD Wiki". You need to PM yorik or jmaustpc to get FreeCAD privileges.
Very classy first post with an offer to contribute. Thanks :)
"fight the good fight"
User avatar
yorik
Site Admin
Posts: 12065
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels, Belgium
Contact:

Re: Posting a new macro

Postby yorik » Sun Jan 31, 2016 3:06 am

I created an account for you aleph0 (our wiki is different from the "original" mediawiki, doesn't take the same credentials, and to avoid spam only admins can create new accounts on ours). You should receive a confirmation email from the wiki. Any problem, just tell us!
aleph0
Posts: 28
Joined: Fri Jan 29, 2016 10:04 am
Location: Cambridge, England
Contact:

Re: Posting a new macro

Postby aleph0 » Sun Jan 31, 2016 5:41 am

OK, the macro should be there now, under Utility, called cross_section.
renatorivo
Posts: 2611
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: Posting a new macro

Postby renatorivo » Sun Jan 31, 2016 8:30 am

Hi aleph0,
I tried the macro with 0.16-dev and I get this error.
Maybe it's a problem of my installation?

Code: Select all

Traceback (most recent call last):
  File "C:/Users/User/AppData/Roaming/FreeCAD/Cross Section.FCMacro", line 477, in <module>
    myWidget = CrossSectionWindow()
  File "C:/Users/User/AppData/Roaming/FreeCAD/Cross Section.FCMacro", line 100, in __init__
    self.child.initUI(self)
  File "C:/Users/User/AppData/Roaming/FreeCAD/Cross Section.FCMacro", line 138, in initUI
    self.hideObjects()
  File "C:/Users/User/AppData/Roaming/FreeCAD/Cross Section.FCMacro", line 351, in hideObjects
    self.updateAxis()
  File "C:/Users/User/AppData/Roaming/FreeCAD/Cross Section.FCMacro", line 445, in updateAxis
    self.updateGui() # recalculate the cross-section
  File "C:/Users/User/AppData/Roaming/FreeCAD/Cross Section.FCMacro", line 397, in updateGui
    c = Part.makeCircle(r, Base.Vector(x, y, z),
<type 'exceptions.NameError'>: global name 'Base' is not defined
OS: Windows 8.1
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6321 (Git)
Build type: Release
Branch: master
Hash: a583697e5a5e3e2c127f5ac5c63dd7668a2d76d7
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17


Renato
renatorivo
Posts: 2611
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: Posting a new macro

Postby renatorivo » Sun Jan 31, 2016 9:43 am

Hi,
missing final }}
now the error is:

Code: Select all

<unknown exception traceback><type 'exceptions.SyntaxError'>: ('invalid syntax', ('C:/Users/User/AppData/Roaming/FreeCAD/Cross Section.FCMacro', 480, 1, '}}\n'))
aleph0
Posts: 28
Joined: Fri Jan 29, 2016 10:04 am
Location: Cambridge, England
Contact:

Re: Posting a new macro

Postby aleph0 » Sun Jan 31, 2016 11:36 am

It probably needs "import FreeCAD". Linux versions seem to do this automatically, but I see you're using Windows so perhaps the Windows one doesn't. I've edited the macro to add that statement. If that doesn't work you might need import FreeCAD.Base as well.