CADText to String with a new line in it

Hello everyone,

i am currently working on a script which imports information about luminares from an AutoCAD drawing. Since i can’t add block informations nor rename the layers my blocks are on, i started working with a schedule i can import via the dwg. (this is the only way i found since we are working with DIALux and it is a pain in the a**).

The import, the translation from CADText to strings and the comparison with my personal excel translation list works just fine. But while scaling it up and adding more and more luminares i came across one which starts a new line in the AutoCAD schedule.

When reading the CADText with the new line in it, Dynamo fills the new line space with a slightly wider space but not a “\n” new line command. So i am not able to compare this string with any other, nor replace the double space with a single one.


I hope the Screenshot is helping to describe my problem. The python script block is just for testing and to show the weird spaces.

Did anyone ever came across this weird and specific problem or has an idea how to tackle my problem? I’ll be forever grateful

Heya,

Would you mind explaining why you can’t replace the double space (with \n)? :slight_smile:

Thanks,

Mark

Hi Mark,
thank you for your reply!

I have not tried that up until now. But the string is still not changing:


Maybe this Screenshot helps explaining the issue.

Best Regards,
Max

Can you send the string to clipboard and look into what the character is in notepad? The Python appears to have nothing in the quotes.

1 Like

Hey,

I agree with Jacob :slight_smile:

Perhaps it should be wert2.Replace(" ", " ")

Cheers,

Mark

First of all i found a workaround, though i am not really happy with it:
I split up the string into a list and put it back together, for some reason it deletes the spaces perfectly

wertsplit = wert2.split()

wert2 = “”

for wert in wertsplit:
if wert2 == “”:
wert2 = wert
else:
wert2 = wert2 + " " + wert

OUT = wert2

Now to your suggestion @jacob.small, thank you for your idea.
I exported the string via the “FileSystem.WriteText” node to a .txt
test.txt (45 Bytes)
For me this looks like a new line created with enter. Even encoding it to utf-8 only sees a new line.

@Mark.Ackerley I tried that as well, it changed nothing. Even replacing (" “,”") just deletes the spaces but not the new line

1 Like

I think that split removes all white space(s), so I guess that’s quite a decent solution in this case :slight_smile:

1 Like

I agree - split is quite elegant. I’d set it up as is and move onto the next issue.

Sadly the encoding is the issue here; you’re not in UTF8, but something else (not sure what).

2 Likes

I already tried to find that out. But sadly i’ve found no fast information about the encoding AutoCAD uses for it’s text blocks.

Thank you for the inspiration to keep on trying guys.

1 Like