Transform cad block into revit family


Sorry to ask this one more time, however, I tried with countless possibilities found in the forum to create the following script; import link cad blocks and convert them into a revit family with the same name.
But none of the attempts were successful.
This time using the function; if the block name is the same as the tal family, import it in the same position.
What could I be doing wrong?
Thank you very much in advance

8º - Automação.dyn (99.8 KB)

1 Like

I think the important part is that you search for and either return or create the family first before placing instances. Once you have the families sorted out, you can create a dictionary of the block name and corresponding family type.

Beyond that, it would be helpful if you could show all the node previews and the warnings so we know what’s going on in your graph.


Yes, understood. However, that’s what I did, I created the families, later the blocks, both with the same name. With that, according to the images, one of the attempts was to select the cad link, create a list of blocks and another of the family, and from there I identified that the block that is in position 2, for example, will be a reference for the position of the family such .
It worked, the routine matters, but if I try to do it with another project, it doesn’t put the blocks in the same position, therefore, it imports all of them in the wrong positions.
I need a form that identifies by name, not by position. But I still couldn’t. :frowning:

8º - Automação.dyn (109.5 KB)

I think a dictionary would be incredibly helpful. That would allow you to get all the blocks and their locations and then convert the block name into the correct family to place.

Ours would be incredible. But I don’t know the node. Which would be? How to use?

The core nodes will work fine. There’s some documentation on them here:
https://primer.dynamobim.org/09_Dictionaries/9-2_Node-uses.html

Not sure if you were intentionally wanting to use the List.RestOfItems node. To clarify, that node takes the very first item out of the input list and returns a list of the rest of the items. Also, you may need to review how you are getting your index numbers and corresponding items at indicies. Below is an example of what I believe you are after. Dictionaries are a powerful option and definitely would be the way to go.

I don’t know if you understand my question. I manage to make the list of blocks, that’s ok, the question is that I cannot identify the names of the blocks when converting them into families, through numbers that represent the position of that block in the list, because, when used with another project, that position may be different.
I need to know a way to tell revit through the names; Is block such, from this list, the same as family such? Without yes, you can replace, if not disregard. How to do with names.
I really appreciate the help so far, but if you can help me with this.

Use List.AllIndiciesOf node to compare your string list, then use the index number returned from that to feed into the List.GetItemAtIndex. Or use the List.Contains option if you need to use bool results also. If none of these work, then I guess I am not understanding everything correctly.

Ah yes, I understand if you don’t understand, my English is really bad :sweat_smile:.
So I thank you even more for your attention and patience. :pray:
But see, it would solve my problem if I could get nodes that replace that number (integer slider) and I could use one to filter by name. But List.getItemAtIndex does not accept string.

Do you know any way to change that part?

No your English is fine. There is probably just some clarification needed. So let’s approach this way. I see the one list of names in the code block. Is the second list of names coming in from the CAD Block?

image

I believe that due to my lack of experience, I am complicating what could be simpler.
In this example of the image I had sent, my reasoning was as follows; I imported the information from the cad link blocks.
I made a list of all the cad blocks I work on in the projects, selected each item through its index, and told the dynamo that the index named “tal” should import the “tal” family in the same position. The revit list now with your question I see that it is not necessary, but it was to create a list of cad blocks, compare it with a list of available families and tell dynamo that when this block is this family.
Because I can’t filter directly from the objects imported from the cad link, because in other projects it will have different blocks.
Now I did the following, I imported my list of possible blocks from excel, I used contains, boolmask and boolean to separate a block by name, what I need, but then I needed to continue and do this, when it is that name, it is that family. and I’m not getting :sob: :sob:

I still think what I posted before will give you what you need. To clarify, I can’t use you script, so I reproduced the results with code blocks. The three blocks that are circled red, represent the information being brought in by the CAD Block node from your example. I am comparing the block names from the BLOCOS code block to the names brought in from the CAD Block node. If there is a match, then I am getting the index number of the block name from the CAD Block node. This index number is being used to get the corresponding point and rotation. I am also providing a reverse of that with getting the index of the name from the BLOCOS code block.

image

I understand your last example. But not sure what you are trying to do with the very last list by boolean mask node. That part doesn’t seem correct.

Oh my God! Helped me a lot!
I did it as follows, I imported cad blocks, and a spreadsheet with the names of the blocks, I filtered the existing ones in the cad.
I made a list of all the blocks, to say which each one will be if it is true in the cad worksheet.
Then the difficulty and doubt remained at this point, which nodes to use to inform the type of family of each block. It should be connected in the parameters and cad block?



Cool! Making progress!

The issue with your select family is that you are feeding a family type into an input that requires a family type name (string). Options:
Either feed the Family Types output straight into the FamilyInstance.ByPoint node as shown with red connector. Or use the Element.Name node to get the name in string format and feed that into the typeName input as shown with the blue arrow.

image

Yes, yes. But here’s the problem: I need to specify the type of family for each block and relate it to the blocks in the project.

In other words, if I find out that the project has “such” blocks, those blocks by default belong to the “such” families.

Because there are multiple types of outlets and switches in each project, you see? So I can’t just have one type, or it would convert all the blocks into a single family type. Watch the video.

The routine should be as follows:

  1. Search for the link and CAD blocks (resolved).
  2. Retrieve a list of all the blocks we use in the projects (resolved).
  3. Analyze which blocks we use that exist within the CAD link (resolved).
  4. Identify and set the standard in Dynamo for each block’s family, meaning that any blocks present in the project will already have their corresponding family defined.
  5. Associate these families with the project so that it can assign each family to its respective points on the blocks.

I have to consider that the routine will be used for multiple projects, so the only thing I will need to input is the selection of the CAD link. The rest should be standardized.
Uploading: Dynamo 2023-06-13 14-48-47.mp4…

This is where the dictionary comes in. If you’ve defined which blocks get converted into which family types, then all you have to do is feed the list of project blocks into the dictionary and it will return the family type required for that block.

1 Like

Okay, then I think the best option for #4 is to setup a dictionary like @Nick_Boyts eluded to. Use dictionary by key and value, where the key is the name of the block and the value is the corresponding family name. Then you can search the dictionary by the key (block name) and have it return the corresponding value (family name) and use that result to get the family type by the name. Below is a short example of how to use a dictionary. There may be other threads that get into more detail.

1 Like

Oh yes, I didn’t know how to use the Dictionary. I tried in several ways yesterday, but I wasn’t successful, so I’ll ask again. I have multiple blocks, okay? And each block will correspond to a family. Therefore, I’ll need to replicate the Dictionary.ValueAtKey for each block (like in the image)? And should I pull the FamilyType.ByFamilyNameAndTypeName node from the Dictionary.ValueAtKey to specify the family? And where should I connect the dictionary in the routine? In the CAD Block input? Thank you once again for all the help. I’ll finish it today and promise not to bother you anymore. Haha… :sweat_smile:

1 Like

The primer section on dictionaries will be very helpful.
https://primer.dynamobim.org/09_Dictionaries/9_Dictionaries-In-Dynamo.html

A dictionary is just a set of named key, value pairs. Every key in a dictionary has a corresponding value. If you feed a list of keys into a dictionary it will return the list of corresponding values. In this case, you’ll want to build your dictionary “manually” so that your list contains all the blocks that could exist in your projects and all the families/types that need to be assigned to those blocks. Once you have the dictionary defined, you can feed it a list of project specific blocks and it will return, in order, the list of families/types that need to be placed at those block locations.

1 Like