How to show plane larger?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

How to show plane larger?

Post by stefankorisnik3 »

I'm showing a plane (Part.Plane). How can i make it larger - wider and longer?

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: English/United Kingdom (en_GB)
Installed mods: 
  * CurvedShapes 1.0.3
  * Curves 0.5.2
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: How to show plane larger?

Post by Syres »

I'm sorry but the amount a topics you have opened in such a short time indicates to me that you're not searching for information beforehand. Do you actually read the Wiki before asking? https://wiki.freecadweb.org/Part_Plane#Scripting
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

Re: How to show plane larger?

Post by stefankorisnik3 »

Thanks. I will pay attention next time.
Can you tell me how can i make the plane larger in every direction?
With the parameters Length and Width i'm getting increasing only by one direction.
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: How to show plane larger?

Post by Syres »

I assume you're saying that you want the increase to be symmetrical about the centre point of the plane. In which case you just add some maths to the position, either in the macro or in an expression in parameter. So Position X would be -Length/2 and Y would be -Width/2 https://wiki.freecadweb.org/Expressions
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

Re: How to show plane larger?

Post by stefankorisnik3 »

Thanks. I tried this but this doesn't seems to work.

Code: Select all

planeObj = App.ActiveDocument.addObject(
			"Part::Plane", "plane")
		planeObj.Shape = myPlane.toShape()
		planeObj.Length = 30
		planeObj.Width = 30
Also tried to add the line:

Code: Select all

planeObj.Placement = App.Placement(myPlane.Position, myPlane.Rotation)
but my plane doesn't show up on the right place.
I know that myPlane is proper oriented i have tried to show it with

Code: Select all

Part.show(myPlane.toShape())
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: How to show plane larger?

Post by Roy_043 »

I don't understand, this works fine:

Code: Select all

planeObj = App.ActiveDocument.addObject("Part::Plane", "plane")
planeObj.Length = 30
planeObj.Width = 30
planeObj.Placement = App.Placement(App.Vector(11, 12, 13), App.Rotation())
App.ActiveDocument.recompute()
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

Re: How to show plane larger?

Post by stefankorisnik3 »

I have already plane
but this line doesn't seem to be suitable:
planeObj.Placement = App.Placement(myPlane.Position, myPlane.Rotation)
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: How to show plane larger?

Post by Syres »

I'm fairly certain you would get an error in the Report View, something starting Exception....Units... perhaps?

Anyway here's a tested macro, hopefully you'll read everything and understand that numbers and units have to match when carrying out maths against them.

Code: Select all

import FreeCAD as App

doc = App.activeDocument()

plane = doc.addObject("Part::Plane", "myPlane")
planeLength = 30                             # This is a plain integer representing a dimention in millimetres
planeWidth = 40                               # This is a plain integer representing a dimention in millimetres
offsetInX = 0                                    # This is a plain integer which can be positive or negative, representing a dimention in millimetres
offsetInY =0                                     # This is a plain integer which can be positive or negative, representing a dimention in millimetres
zPos = 3                                             # This is a plain integer which can be positive or negative, representing a dimention in millimetres
xPos = offsetInX-planeLength/2
yPos = offsetInY-planeWidth/2
plane.Length = planeLength
plane.Width = planeWidth
centreOfPlane = FreeCAD.Vector(xPos,yPos,zPos) # This is now a matrix of metric positions in millimetres
rot = FreeCAD.Rotation(FreeCAD.Vector(0,0,1),0)
newplace = FreeCAD.Placement(centreOfPlane,rot,centreOfPlane)
plane.Placement = newplace

doc.recompute()
Post Reply