Problem about convert CAD point to Revit.

Problem about convert CAD point to Revit.

NGM_AiYo
Advocate Advocate
468 Views
4 Replies
Message 1 of 5

Problem about convert CAD point to Revit.

NGM_AiYo
Advocate
Advocate

I made the plugin that put the Link CAD drawing turning water pipe model.

Using Teigha to read dwg file data.

The problem is the transformation of point coordinates.

Under normal circumstances, convert the coordinate unit and then convert it with the Transform from ImportInstance.

But when the whole drawing deviates far from the CAD origin, this calculation method will not work.

I would like to understand the way Revit converts coordinates in this particular case.

0 Likes
Accepted solutions (1)
469 Views
4 Replies
Replies (4)
Message 2 of 5

NGM_AiYo
Advocate
Advocate

nobody knows?

 

0 Likes
Message 3 of 5

NGM_AiYo
Advocate
Advocate

I found that the new origin of the dwg drawing is about its center position, but how this center is calculated, I have no clue.

 

1689932170887.png

upper two detail lines' intersection is the center of dwg link in revit.

lower three detail lines' intersection is the new origin of the dwg.

0 Likes
Message 4 of 5

jeremy_tammik
Alumni
Alumni
Accepted solution

This sounds more like an end user issue than a programming problem to me. The Revit API is just a wrapper for the standard UI functionality. So, it will probably be most effective to solve this from an end user UI perspective first, before trying to address anything programmatically with the API. For the UI solution, you might want to first check the online help topics on linking a DWG into a Revit project, and then if needed receive more support in the general architectural forum:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 5

NGM_AiYo
Advocate
Advocate

After these days of research, I have found a method that works well.

Using the ImportInstance BoudingBox, calculate its center point p1.

Using Teigha, read the dwg link file,  the DataBase of dwg file has ExtMin and ExtMax property.

using this two point, calculate dwg center point p2.

Transform p2 from millimeter to feet.

p1 - p2 , you get a vector that you can transform the location data, read in dwg file.

1690337048828.png

result has a little offset, because the two centers don't exactly coincide.

So the best option is to check and readjust the origin of the dwg file before linking it.