Skip to content

Commit

Permalink
Adjusted camera to fit prewview.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmplonka committed Aug 7, 2019
1 parent c8962b9 commit cd941b4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
14 changes: 8 additions & 6 deletions README.md
@@ -1,12 +1,12 @@
# InventorLoader
Loads / Imports Autodesk (R) Inventor (R) files into FreeCAD (min. Version 0.17). Until now only
Loads / Imports Autodesk (R) Inventor (R) files into FreeCAD (min. Version 0.17). Until now only
Parts (IPT) but nor assemblies (IAM) nor drawings (IDW) can be displayed.

As Inventor files contains a complete ACIS model representation, SAT and SAB files can also be
As Inventor files contains a complete ACIS model representation, SAT and SAB files can also be
imported into FreeCAD.

## Status:
> Release Candidate 1 (RC1)
> Release Candidate 2 (RC2)
## Prerequisites
- The AddOn requires additional python packages in the FreeCAD python installation:
Expand All @@ -26,10 +26,10 @@ a) beside FreeCAD's bin folder, or
b) in user's application data (%APPDATA% on windows) or home folder (on linux/MAC).
A new folder "InvetorLoader-master" will be created.

The next time FreeCAD will offer new import formats for ACIS' SAT (\*.sat) files and Autodesk
The next time FreeCAD will offer new import formats for ACIS' SAT (\*.sat) files and Autodesk
Inventor's IPT (\*.ipt) files as supported import formats.

As new python packages are required (ref. "Prerequisites") FreeCAD has to be restarted
As new python packages are required (ref. "Prerequisites") FreeCAD has to be restarted
so that the new packages become available.

### Solving installation problems
Expand Down Expand Up @@ -80,7 +80,9 @@ That allows it to embed Excel workbooks e.g.
-- STEP based: The ACIS model will be converted into STEP and imported afterwards.

## History:
- 0.17.0 (2019-07-04): Missing features added as ACIS models.
- 0.18.0 (2019-08-07): Added coloring of single faces and changed to default Inventor campera position (RC2).

- 0.17.0 (2019-07-04): Missing features added as ACIS models (RC1).

- 0.16.0 (2019-03-19): Added creation of Shells

Expand Down
3 changes: 0 additions & 3 deletions TODOs.md
@@ -1,7 +1,4 @@
# IPT file
## Incomplete Features
* Colors
* single faces

## Missing Features
* SheetMetal
Expand Down
23 changes: 20 additions & 3 deletions importerIL.py
Expand Up @@ -5,11 +5,12 @@
Collection of 3D Mesh importers
'''

import os, sys, FreeCAD, importerSAT, Import_IPT
import os, sys, FreeCAD, FreeCADGui, importerSAT, Import_IPT
import importerUtils, Acis, importerClasses
from importerUtils import canImport, logWarning, logError, logAlways, viewAxonometric
from importerUtils import canImport, logInfo, logWarning, logError, logAlways
from olefile import isOleFile
from importerFreeCAD import createGroup
from pivy import coin

__author__ = "Jens M. Plonka"
__copyright__ = 'Copyright 2018, Germany'
Expand Down Expand Up @@ -70,6 +71,19 @@ def releaseMemory():
Acis.releaseMemory()
importerClasses.releaseModel()

def adjustView(doc):
if (FreeCAD.GuiUp):
# adjust camara position and orientation
g = FreeCADGui.getDocument(doc.Name)
v = g.ActiveView
c = v.getCameraNode()
p = coin.SbVec3f(1, 1, 1)
o = coin.SbVec3f(0, 0, 0)
u = coin.SbVec3f(0, 1, 0)
c.position.setValue(p)
c.pointAt( o, u )
FreeCADGui.SendMsgToActiveView("ViewFit")

def insert(filename, docname, skip = [], only = [], root = None):
'''
opens an Autodesk Inventor file in the current document
Expand All @@ -86,6 +100,8 @@ def insert(filename, docname, skip = [], only = [], root = None):
reader.create3dModel(group, doc)
viewAxonometric()
releaseMemory()
FreeCADGui.SendMsgToActiveView("ViewFit")
logInfo(u"DONE!")
except:
open(filename, skip, only, root)
return
Expand All @@ -104,6 +120,7 @@ def open(filename, skip = [], only = [], root = None):
if (reader is not None):
# Create 3D-Model in root (None) of document
reader.create3dModel(None , doc)
viewAxonometric()
adjustView(doc)
releaseMemory()
logInfo(u"DONE!")
return
8 changes: 1 addition & 7 deletions importerUtils.py
Expand Up @@ -10,7 +10,7 @@
from PySide.QtGui import *
from uuid import UUID
from struct import Struct, unpack_from, pack
from FreeCAD import Vector as VEC, Console, GuiUp, ParamGet
from FreeCAD import Vector as VEC, Console, ParamGet
from olefile import OleFileIO

__author__ = 'Jens M. Plonka'
Expand Down Expand Up @@ -851,12 +851,6 @@ def setInventorFile(file):
shutil.rmtree(p)
return OleFileIO(file)

def viewAxonometric():
if (GuiUp):
FreeCADGui.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
logInfo(u"DONE!")

def isString(value):
if (type(value) is str): return True
if (sys.version_info.major < 3):
Expand Down

0 comments on commit cd941b4

Please sign in to comment.