DC - Is there a way to copy/paste an attribute, or is there a hack to copy all the List items to another attribute list


F.e as an sample case to make it clear what I need.
I’am creating a concrete foundation with insulation like EPS. I want to make it so that the user can set the thickness of the front insulation, the under ( between dirt and beam ) insulation, the back side ( inner ) insulation and so on.
This means I have to make 3 or more lists where the user can choose from the different thickness and pressure ( like EPS100, EPS150 or EPS 250 e.t.c ). That means I will be two hours typing with unless someone has a great tip, on how to copy that.

However, In the meantime I was try to do so in code, but…

so far, I came up with ( for this sample I did use Stacy in a new model )

  UI.menu("Plugins").add_item('add a list') {
  mydc = Sketchup.active_model.entities[0]
  fnd_def = mydc.definition
  fnd_def.set_attribute 'dynamic_attributes', 'fndeps', '5'
  fnd_def.set_attribute 'dynamic_attributes', '_fndeps_label', 'Thickness2'
  fnd_def.set_attribute 'dynamic_attributes', '_fndeps_formlabel', 'Thickness3'
  fnd_def.set_attribute 'dynamic_attributes', '_fndeps_units', 'CM'
  fnd_def.set_attribute 'dynamic_attributes', '_fndeps_access', 'List'
  fnd_def.set_attribute 'dynamic_attributes', '_fndeps_options' , '50 mm=5'&'100 mm=10'&'200 mm=20'

I got an error ( however it looks like a Component options window error ) and also no list.
ERROR: Error: Callback function error: undefined is not an object (evaluating ‘conv.unitsHash[units].template’) @ /dcbridge.js[601].
What do I wrong?

Also how can I directly search for a named component using the name of the component?

Thank you


Use attribute inspector and copy the _attributeName_options values and place in the corresponding DC


And the options data field may also be URL encoded (if memory serves.).

Via Ruby … (I think) …

require 'uri'

opts = Hash[
  '50 mm',   '5',
  '100 mm', '10',
  '200 mm', '20'
opts_dc = URI.encode_www_form( opts )


URI module

URI::encode_www_form module function.


@pcmoor Thank you.
I did download it right away.

In meanwhile i figured it out what went wrong. I did OVERLOOK something. I HAVE TO TYPE ‘LIST’ IN CAPITALS, I GUESS I WAS A LITTLE BLIND.

I got it working.

@DanRathbun I will try to implement your idea as well. even quicker to make a list.


It is silly that the DC code does not use case-insensitive comparison of the attribute access type.


Not sure about that, it is a Keyword. It was my own fault. I should have look better at the text, all the others where in capitals, so why not ‘List’.


Further to this list production, as most data is accessible to excel or other spreadsheets, a macro script can convert the two columns to a string with the appropriate delimiters.
As this forum does not allow me to post an actual working spreadsheet. You (or any interested party) would need to PM their email address to receive an example

Sub Macro1()

Dim i As Integer, astr As String, bstr As String, total As String

For i = 0 To Selection.Rows.Count - 1

    astr = ActiveCell.Offset(i, 0)
        Do While InStr(1, astr, " ")
            pos = InStr(1, astr, " ")
            astr = Mid(astr, 1, pos - 1) & "%20" & Mid(astr, pos + 1)
    bstr = ActiveCell.Offset(i, 1)
        Do While InStr(1, bstr, " ")
            pos = InStr(1, bstr, " ")
            bstr = Mid(bstr, 1, pos - 1) & "%20" & Mid(bstr, pos + 1)
    total = total & "&" & astr & "=" & bstr

ActiveCell.Offset(Selection.Rows.Count, 0) = total & "&"
End Sub


Hi, thank you for the invitation. I will do. Always interested.

However I did have the list in my spreadsheet, I did use tekst.samenvoegen ( text.concat? ) for each row to get the textual representation. Then concats all the rows. Copy past into the code. For now okay and fast. I will use something like your code as an UDF and a range to build something to work with a real extension.

2 year member. Jummy, a cake. Seriously I just finished one ( this is my lady’s one. I hope she forgets ;p )


update on VBA code

Sub Macro1()

Dim i As Integer, astr As String, bstr As String, total As String

For i = 0 To Selection.Rows.Count - 1

    astr = ActiveCell.Offset(i, 0)
    If Not astr = "" Then
        astr = URLEncode(astr, False)
        bstr = ActiveCell.Offset(i, 1)
        bstr = URLEncode(bstr, False)
        total = total & "&" & astr & "=" & bstr
    End If

ActiveCell.Offset(Selection.Rows.Count, 0).Select
ActiveCell = total & "&"

End Sub

Public Function URLEncode( _
   StringVal As String, _
   Optional SpaceAsPlus As Boolean = False _
) As String

  Dim StringLen As Long: StringLen = Len(StringVal)

  If StringLen > 0 Then
    ReDim result(StringLen) As String
    Dim i As Long, CharCode As Integer
    Dim Char As String, space As String

    If SpaceAsPlus Then space = "+" Else space = "%20"

    For i = 1 To StringLen
      Char = Mid$(StringVal, i, 1)
      CharCode = Asc(Char)
      Select Case CharCode
        Case 97 To 122, 65 To 90, 48 To 57, 45, 46, 95, 126
          result(i) = Char
        Case 32
          result(i) = space
        Case 0 To 15
          result(i) = "%0" & Hex(CharCode)
        Case Else
          result(i) = "%" & Hex(CharCode)
      End Select
    Next i
    URLEncode = Join(result, "")
  End If

'refer source: https://stackoverflow.com/questions/218181/how-can-i-url-encode-a-string-in-excel-vba
End Function


Even better. Copy past into my snippets.

Thnk you


XLSX and Attributes

Hi, this is nice.
Is that a self written excel macro, or is this downloadable?


The excel sheet I private message prior contains the userform as per the video. Once you have referenced the start macro preferably via a button, the userform works on any worksheet.


Oke, thank you.

Your Mail did sit in my spambox. I will try it out.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.