CAD Block location

Hi there,

What I’m trying to achive is to get location of some Cad blocks from a Cad file inserted as a link in Revit.

Right now, I’m using an Excel file got from AutoCad and then I use dynamo to insert a family instance by point.

I would like sth without using Excel, because those Cad blocks have geometry parameters with the location, so if I could read them, it’s gonna be faster than create an Excel file and…

I’ve tried with ActiveX package ans DynamoCad package, but nothing works.

Any Idea?

Thks

Manel

imagen

Have you looked into what you can access via the dataextraction command in AutoCAD?

Using dataextraction I can get what I want. x,y.z geometry and the block name.

I can get that, buy I dont want to do it with an excel file. I want to do it directly from Dynamo.

manel

What type of blocks are they, can you post a copy?

1 Like

Does the GIF below demonstrate what you want to do?
20180607-cadBlockOrigin

If so, here is the python script to get the origin of a CAD import.

#Copyright(c) 2018, parallax team
#@prlxTeam
import clr

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk

#Custom tolist definition provided by Dimitar Venkov
#https://github.com/dimven/SpringNodes
def tolist(x):
	if hasattr(x,'__iter__'): return x
	else : return [x]

#unwrap all elements to use with API
items = tolist(UnwrapElement(IN[0]))

#lists to append results to
locations = list()

#iterate through the cad imports
for i in items:
	transform = i.GetTotalTransform()
	locations.append(transform.Origin.ToPoint())

#Assign your output to the OUT variable
OUT = locations
4 Likes

Hi there!

First of all, thks for your answers.

@Ewan_Opie
Find attached a capture of the cad file:

As you can see, there are some blocks in the same cad. They are some ligthing fixture, each block has a geometry with the location, so, I just need to read them in order to set my objects in Revit.

@john_pierson
I would need to know the location of blocks inside the Cad file instead of the origin of a cad file.

I would need to find for each block named “blablabla” the location “XYZ”.

Thks again

Manel

1 Like

I have the same issue with active x the file package :frowning:

Don’t know why, but sometimes works, sometimes doesn’t.

Manel

while run the dyn you should open the related autocad file…

Sorry all wrong topic.

[quote=“MOJTABA256, post:12, topic:22538, full:true”]
Thanks John for your solution but unfortunately it doesn’t work for me your python script. I imported the CAD geometry (for lighting fixtures) in Revit and tried to use your code but it didn’t work. I want to replace them with a lighting fixture Revit Family, but the script couldn’t find the CAD blocks coordinates. Could u please help me to solve this solution? Thanks

Hi,

Use the CAD Block node of the Genius Loci package for this task.
CAD Link

1 Like

Thanks Alban. It helped a lot. But when I ran the script I saw that the direction of my Revit elements are not correct according to the angle of my CAD Blocks as shown below.

Do you know how I can solve this issue?

Thanks

Use the output Rotation of the CAD Block node :

1 Like

Thank you so much Alban for your great solution. But I do not know why my Revit elements are still a bit OFF as shown below:

Is there any way to exactly place Revit families on the CAD blocks in Revit?
Thanks :slight_smile:

Make sure that the origin of the CAD block and the origin of the family are the same.
You probably have an offset somewhere.

2 Likes

I did a simple model to test from the scratch. I opened a new Revit file, placed some lighting fixtures, exported it as DWG, and then opened a new Revit project (ELEC Template), imported the DWG file, and ran the script. They are still OFF although, as shown below, the location coordinates of CAD Blocks and Revit Elements are the same.

Do you know how to solve this issue? Do you have an example to show me?

Thanks in advance

Double check the origin of your fixture family. It is not possible that there is an offset with identical location coordinates unless the origins of CAD block and family are different.
It is working fine with the french Revit Electrical template.


1 Like