[Solved] Help to offset a line in Arch WB

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
johnwang
Veteran
Posts: 1339
Joined: Sun Jan 27, 2019 12:41 am

[Solved] Help to offset a line in Arch WB

Post by johnwang »

Hi,

In Arch WB:
1. I drew a Line
2. Selected it
3. Click Offset tool
Why it tells me: Either Part.Wire or Part.Edges should be provided, returning None

The line is: FreeCAD.ActiveDocument.addObject("Part::Line", "Line")
How do I change Part::Line to Part.Wire?
or which tool draws Part.Wire directly?

Regards,

John
Last edited by johnwang on Thu Dec 09, 2021 11:28 am, edited 1 time in total.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
Roy_043
Veteran
Posts: 8411
Joined: Thu Dec 27, 2018 12:28 pm

Re: Help to offset a line in Arch WB

Post by Roy_043 »

You probably need to uncheck: Edit → Preferences... → Draft → General settings → Use Part Primitives when available

But IMO the Draft_Offset command should be able to handle a Part_Line. So that would need to be fixed.
User avatar
Roy_043
Veteran
Posts: 8411
Joined: Thu Dec 27, 2018 12:28 pm

Re: Help to offset a line in Arch WB

Post by Roy_043 »

paullee
Veteran
Posts: 5092
Joined: Wed May 04, 2016 3:58 pm

Re: Help to offset a line in Arch WB

Post by paullee »

Wow, that's quick 8-)
User avatar
johnwang
Veteran
Posts: 1339
Joined: Sun Jan 27, 2019 12:41 am

Re: Help to offset a line in Arch WB

Post by johnwang »

I overwrote that two py files. Got this message:

Code: Select all

09:05:29  Loading GUI of Sketcher module... done
09:05:29  ----------------
09:05:29  GuiCommand: Line
09:05:29  Pick first point
09:05:29  Pick next point
09:05:40  ----------------
09:05:40  GuiCommand: Offset
09:05:40  Pick distance
09:05:42  the offset tool is currently unable to offset a non-Draft object directly - Creating a copy
09:05:42   something wrong with firstDir 
09:05:42  Traceback (most recent call last):
  File "H:\FreeCAD_0.20.26155_Win-LPv12.5.4_vc17.x-x86-64\Mod\Draft\draftutils\todo.py", line 167, in doTasks
    Gui.doCommand(string)
  File "<string>", line 1, in <module>
  File "H:\FreeCAD_0.20.26155_Win-LPv12.5.4_vc17.x-x86-64\Mod\Draft\draftfunctions\offset.py", line 136, in offset
    newobj.Shape = DraftGeomUtils.offsetWire(obj.Shape,delta,occ=True)
TypeError: {'sclassname': 'class Base::TypeError', 'sErrMsg': "type must be 'Shape', not NoneType", 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': "type must be 'Shape', not NoneType", 'btranslatable': False, 'breported': False}

09:05:42  Traceback (most recent call last):
  File "H:\FreeCAD_0.20.26155_Win-LPv12.5.4_vc17.x-x86-64\Mod\Draft\draftutils\todo.py", line 167, in doTasks
    Gui.doCommand(string)
  File "<string>", line 1, in <module>
  File "H:\FreeCAD_0.20.26155_Win-LPv12.5.4_vc17.x-x86-64\Mod\Draft\draftfunctions\offset.py", line 136, in offset
    newobj.Shape = DraftGeomUtils.offsetWire(obj.Shape,delta,occ=True)
TypeError: {'sclassname': 'class Base::TypeError', 'sErrMsg': "type must be 'Shape', not NoneType", 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': "type must be 'Shape', not NoneType", 'btranslatable': False, 'breported': False}

09:05:42  ToDo.doTasks, Unexpected error:
<class 'TypeError'>
in ['offst = Draft.offset(FreeCAD.ActiveDocument.Line, FreeCAD.Vector(-10.67492775865126, 18.22273918977719, 30.16078215968867), copy=True, occ=True)', 'FreeCAD.ActiveDocument.recompute()']

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.26155 (Git)
Build type: Release
Branch: master
Hash: 0926a4148bcff11249fd4f56bc30256102ffe105
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/United States (en_US)
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
Roy_043
Veteran
Posts: 8411
Joined: Thu Dec 27, 2018 12:28 pm

Re: Help to offset a line in Arch WB

Post by Roy_043 »

The problem is caused by occ=True and not related to this PR.
https://wiki.freecadweb.org/Draft_Offset wrote:OCC-style ... only works for planar Draft objects with at least two straight edges.
User avatar
johnwang
Veteran
Posts: 1339
Joined: Sun Jan 27, 2019 12:41 am

Re: Help to offset a line in Arch WB

Post by johnwang »

Roy_043 wrote: Wed Dec 08, 2021 8:28 am The problem is caused by occ=True and not related to this PR.
Where is this occ setting? I can't find it under Draft Preferences.

BTW: I was trying Design456. It has one line 'import occ' and my system reports there is no module named occ. Maybe my FC version has problem with occ not setting right.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
Roy_043
Veteran
Posts: 8411
Joined: Thu Dec 27, 2018 12:28 pm

Re: Help to offset a line in Arch WB

Post by Roy_043 »

johnwang wrote: Wed Dec 08, 2021 10:45 am Where is this occ setting?
It's a checkbox on the task panel.
User avatar
johnwang
Veteran
Posts: 1339
Joined: Sun Jan 27, 2019 12:41 am

Re: Help to offset a line in Arch WB

Post by johnwang »

Roy_043 wrote: Wed Dec 08, 2021 12:16 pm It's a checkbox on the task panel.
I saw this 'occ=True':

Code: Select all

>>> Gui.runCommand('Draft_Offset',0)
>>> offst = Draft.offset(FreeCAD.ActiveDocument.Line, FreeCAD.Vector(-7.045367820091163, 10.100797605951575, 17.52369468323241), copy=True, occ=True)
What is task panel?
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
Roy_043
Veteran
Posts: 8411
Joined: Thu Dec 27, 2018 12:28 pm

Re: Help to offset a line in Arch WB

Post by Roy_043 »

Attachments
task-panel-occ-style.png
task-panel-occ-style.png (7.31 KiB) Viewed 1651 times
Post Reply