Hi all,
How can you get the "default" lineweight in RealDwg? As far as I know in RealDwg you cannot access to AutoCAD System Veriables (i.e. LWDEFAULT). In my case I have an entity, where:
entity.LineWeight returns "LineWeight.ByLineWeightDefault"
Database.Celweight returns "LineWeight.ByLayer"
layer.LineWeight returns "LineWeight.ByLineWeightDefault"
(I'm fallen into a loop!!!) when I open the DWG file in AutoCAD and run "lineweight" command, in the 'Lineweights Settings' dialog box I can see that the default is "0.25mm". This is what I need to get at in my program. I know that the system veriable "LWDEFAULT" give me "25" which is fair enough and I can convert it to LineWeight enum in my program, but the problem is I cannot find any way to get hold of that system variable.
Here I have been advised that "LWDEFAULT isn't a pre-drawing setting - it's stored in the Registry:"
HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R20.0\ACAD-E001:409\Profiles\<<unnamed profile="">>\General\LWDEFAULT
1. Firstly I'm not sure if this works all the time, suppose you develop an application and pass it to a user, where he/she hasn't got AutoCAD installed (i.e. you ship your app with RealDwg only). In this case the above-mentioned registry key will NOT be available on user's machine.
2. Secondly, digging out the registry entries just to get LWDEFAULT from seems to be utterly painful and over the top.
Many thanks for the help in advance.
Hello Hassan Khademi,
The default lineweight value is stored in the registry.
AutoCAD stores this value under its “Profiles\Profile name\General” registry key as LWDEFAULT value.
Other RealDwg host applications need to retrieve/store the LWDEFAULT value under their registry product root key.
The “HostApplicationServices.GetEnvironmentVariable” virtual method can be overridden in your RealDwg application to provide access to the
system variable. This is similar to what AutoCAD does with its “Application.GetEnvironmentVariable”
Regards,
Balaji
Hi Balaji,
So the only way is to dig it out of the registry 😞 .
however I'm still confused how it works when a file is accessed from another machine. Suppose on Computer_1, I have setup the default lineWeight to 0.25mm and created a DWG file. On Computer_2 I have setup the default lineweight to 0.50mm. If I read the file in Computer_2, what do I get as the default lineWeight? 0.25mm or 0.50mm?
Obviousely I need to get 0.25mm in this case, because I need to get access to the settings on the original file rather than the settings on my owm machine.
p.s. In my posts (our conversations) I would rather to be called "KhademiH" rather than my full name. Thanks for understading this.
Sorry for the delay. I had to attend to some other tasks.
Also, sorry about using your full name. I could not edit the reply because it has timed out.
In the example that you mentioned, if the drawing is taken to another system that has a LWDEFAULT set to 0.5 mm, I would expect the line weight to display as 0.5 mm and not using the original LWDEFAULT value of 0.25 mm.
To get the behavior that you mention, you will need to set the current lineweight. In that case, the lineweight is a database property and can be accessed using the "Database.Celweight".
Regards,
Balaji
Hi Balaji,
This behaviour has caused a lot of grief here. And I'm talikng about thousands of entities within hunderds of charts which we have in every single project that we do. This is what happens:
In fact I seem to have no fix for the problem and it seems to be my fault as I didn't design our app correctly in first place due to my wrong assumptions about "Lineweight"(s) in AutoCAD 😞
I am sorry to hear that and not being able to help.