RPS: Cannot import name ExporterIFCUtils - api

With the revitpythonshell 2020 I try to import the class ExporterIFCUtils
from Autodesk.Revit.DB.IFC import ExporterIFCUtils
and get the error:
"Exception : IronPython.Runtime.Exceptions.ImportException: Cannot import name ExporterIFCUtils"

#StefanAnd you'll need to add a reference to the RevitAPIIFC.dll first:
>>> clr.AddReference("RevitAPIIFC")
>>> from Autodesk.Revit.DB.IFC import ExporterIFC
>>> ExporterIFC
<type 'ExporterIFC'>
>>>
It's a bit weird, since it looks like you're importing from a module, but it's a .NET "namespace". These can span multiple assemblies as in the case here, so first referencing the RevitAPIIFC.dll will populate the namespace with the types you expect. Sadly, the Revit API documentation doesn't actually seem to provide the assembly names. At least, I couldn't find them...

Related

Dictionary not defined after module import with this dictionary Python 3.4

I guess, I still don't fully understand scope rules in python (Was sure I do!), so please answer with some explanation.
I wrote module like this:
import pickle
question_dictionary = {}
#few not important definitions of functions
def functionA():
blabla
def functionB():
blabla
#and few classes
def Class1:
blabla
#and here was my last class, maybe important for this problem:
def Class2:
def __init__(self)
blabla
question_dictionary[blabla] = self
So, I import this file in interactive mode. Classes work good, also functions. But when i type in interactive mode question_dictionary I got information, that it's not defined. I don't understand why.
I tied to initialize another dictionary in interactive mode, and it work, the code "dictionary = {}" is valid.
I also tried to comment out the last lines:
question_dictionary[blabla] = self
But I still got problem, "NameError: name 'question_dictionary' is not defined"
Your dictionary is part of the globals of your module. You can reference it as such:
import yourmodule
yourmodule.question_dictionary
Globals are always per module, and your interactive interpreter namespace is really a module too (called __main__). You can create a new reference in that namespace by using from ... import ...:
from yourmodule import question_dictionary
# now question_dictionary is another reference to the same dictionary

Create Category Getting Error "cannot define category for Undefined class"

I am facing a problem when i try to create 2 category of my OWN Simple Class ( Class name is Car). I created 2 Category for this class just for testing " Car+show.h" & "Car+Protected.h". I Just write very small methods in to all like NSLog something sting. My Problem is that when i build application I am getting error into Category File " Can not define Category for Undefined Class Car". Please Suggest me where i am Wrong.
If you import the category header files into Car.h, and your category header files themselves import Car.h, then you have a circular import which is causing you your problems.
Categories are for adding functionality to a class or splitting an interface out across several headers. If you are importing your category headers into your main class header, this is defeating the point.
The category headers should only be included by files that need to use functionality defined in the category.
I have solved my problem luck by chance. I really don't know actual fact about that.
The point is that when i import that category files into Car.h file that time it's create error which i shared with you. But when i Import that same file only and only Car.m file it's work fine.
I really don't know why it's create error when i import that category files into .h file. Please explain why it's getting error?
Thanks Mukesh

importing a module from input

Forgive a noob. This may be beyond me.
I currently import variables from a module via
from a import *
What I aim to do is import the file as per the input string.
mod=str(input("Select a module: "))
from str(mod) import *
This is what I tried. Clearly wrong. I would like the code to ask for an input, which would be the name of a specific module, then import what the user inputs.
Sorry I can provide any more code, the nature of the question prevents me from being capable of showing what I need
You can simply use __import__():
>>> d = __import__("datetime")
>>> d
<module 'datetime' from 'C:\\Python33\\lib\\datetime.py'>
For a more sophisticated importing I suggest using importlib.
EDIT1 to make it more clear:
>>> mymodule = __import__(input("Which module you want?" ))
>>> mymodule.var1
If you want var1 instead of mymodule.var1, I would make aliases to the global namespace. However, I wouldn't do that since I do not see any sense in that.

how to import one project(.zexp file) to another project?

can any one tell how to solve
TypeError:('object.__new__(X): X is not a type object (classobj)', <function
_reconstructor at 0xb766fa04>, (<class DateTime.DateTime.DateTime at 0x9382d4c>, <type
'object'>, None))
while importing a one project(for ex. brundelre3.zexp file) to another in zmi.
I tried it importing the project(brundelre3.zexp) already in zmi under / ->import/export (tab)-> import file name ->ownership-> selected the radio button of Retain existing ownership information-> import (button) so it worked properly before but its not working now . Can anyone tell whats the reason for my error.
I can only make wild guesses, you probably need to debug it:
Perhaps you have created a type that has a name that clashes with something built-in.

InvalidDataContractException was handled

I am getting the following error when try to import an xmlschema using datacontract serializer:
Invalid type specified. Type with name 'ArrayOfanyType' not found in schema with namespace 'http://schemas.microsoft.com/2003/10/Serialization/Arrays'.
I know it happened because I am using a List but how would I get around it? by using
knownTypes.Add(typeof(????))
thanks.
You'd need to share the XSD bit here. My guess is that one of the elements in the schema is of type xs:any. Assuming you meant you are using svcutil to import the info, you need to use svcutil /t:xmlserializer to import the schema.