PDA

View Full Version : Script to change certain linetypes to another?



spittle
28th May 2008, 09:38 am
Would it be possible to create some kind of script to search through all layers in a DWG and change for example all 'Center' linetypes to 'Center2', and all 'Dashed' to 'Dashed2' etc?

Also could it be cleverer and search within a linetypes name so it could pick up these linetypes is they're from an XREF & beginning with eg 'XREF1Center' and changing it to 'Center'

Also, anyone fancy writing a script for this? :D

Currently we don't have any decent standards in our company, I'm in no position to create any so am trying to find a quick fix rather than changing everything manually to make linetypes display correctly.

NBC
28th May 2008, 09:41 am
1. "All linetypes of entities should be set to be BYLAYER." That should be the first line in your standard on linetypes.

LCE
28th May 2008, 09:51 am
Would it be possible to create some kind of script to search through all layers in a DWG and change for example all 'Center' linetypes to 'Center2', and all 'Dashed' to 'Dashed2' etc?

Also could it be cleverer and search within a linetypes name so it could pick up these linetypes is they're from an XREF & beginning with eg 'XREF1Center' and changing it to 'Center'

Also, anyone fancy writing a script for this? :D

Currently we don't have any decent standards in our company, I'm in no position to create any so am trying to find a quick fix rather than changing everything manually to make linetypes display correctly.
Quick answer, Yes.
I can put something together in VBA if you want, with a Form and 2 drop-down lists to select. It will only list the linetypes that are already loaded though.

spittle
28th May 2008, 10:24 am
LCE - Yeah that would be great!

NBC - Yes you're right, Currently I'm receiving drawings from contractors, surveyors, colleauges. Some are good, some are crap! Some drawings contain a mixture of imperial & metric linetypes, some a scaled by overiding the entity in properties. Also some of my superiors may find it a bit arrogant of me to try and start telling them how they should be doing their drawings as I was only promoted from a junior last month, even though some of their drawings really suck!

I want to be able to quickly, set all linetypes to by layer, and linetype scale 1, and then change all of them to use the default linetypes which end with number 2. This is because the linetypes that don't end with 2, eg 'center' look far too big when used with linetypes containing text.
Luckily, both the imperial & metric .lin files contain identical linetype names so the relevant one can be loaded easily and if linetypes are included in a drawing that arn't written in both the metric & imoperial .lin files, then I can just load the other .lin file and change the Global Linetype Scale.

Hope that makes sense!

LCE
28th May 2008, 10:40 am
See attached.
Let me know if you need any help with this.

spittle
28th May 2008, 11:09 am
Hello mate, how do I load that? I had someone have go who's had some experience with writing VBA but no luck so far.

Cheers

Dave

LCE
28th May 2008, 11:19 am
Just made 1 little change.
To load it type -vbarun at the command line and then

"filepath\ltset.dvb!Start"

Where filepath is the location of the ltset.dvb

Let me know if you need any more help with this.

spittle
28th May 2008, 11:31 am
Hi

I've got this working but in the existing lt dropdown it contains all the linetypes from the .lin file that the drawing is using, even though I've purged out all the linetypes not needed. This would involve changing a silly number of linetypes when it's not needed.

Thanks for trying though

Dave

*EDIT*

I think these linetypes are being loaded from my XREFs, also is there a way to change the second dropdown to display only the linetypes in my .lin file, rather than having all the ones nested in the XREFs as well?

LCE
28th May 2008, 12:59 pm
Hi

I've got this working but in the existing lt dropdown it contains all the linetypes from the .lin file that the drawing is using, even though I've purged out all the linetypes not needed. This would involve changing a silly number of linetypes when it's not needed.

Thanks for trying though

Dave

*EDIT*

I think these linetypes are being loaded from my XREFs, also is there a way to change the second dropdown to display only the linetypes in my .lin file, rather than having all the ones nested in the XREFs as well?
Yes, should be simple enough. I will try and have a look this afternoon.

spittle
28th May 2008, 01:44 pm
Great, thanks, don't suppose there's any way to do a search within VBA? So any linetype containing 'center' could be picked up automatically?

Eg "XREF12314144linetypecenter"

No sweat if it's not possible!

LCE
28th May 2008, 02:04 pm
Yeah, that can be done.
I will have a play when I get some time this afternoon and give you a few options.

spittle
28th May 2008, 02:36 pm
Cool, thanks

Dave

LCE
28th May 2008, 05:10 pm
Cheeky so'n'sos.
6 downloads but only Dave says anything...no gratitude these days, everyone just wants something for nothing.

Bye bye Mr Attachment.

SEANT
28th May 2008, 11:00 pm
I would not take it personally. Not so many people are keen on running code at which they can’t first take a peek. It could make for an uncomfortable conversation with IT if it turned out malicious.

Why password protection? Exposing the code is more in keeping with the CADTUTOR tradition. It is also makes for a more effective demonstration of a clever an industrious coder.

LCE
29th May 2008, 08:03 am
I would not take it personally. Not so many people are keen on running code at which they can’t first take a peek. It could make for an uncomfortable conversation with IT if it turned out malicious.

Why password protection? Exposing the code is more in keeping with the CADTUTOR tradition. It is also makes for a more effective demonstration of a clever an industrious coder.
Password protected was for the case of exactly what happened this time.
I really don't feel like posting code, however basic it may be when people are just going to hit and run.
Posting the file the OP needs to acheive what he is after is fine, I am happy to do that, but posting the code, not going to happen any more.

SEANT
29th May 2008, 09:37 am
As I’m sure you’ve gathered, I was one of the six original downloaders. I didn’t trial or comment on the routine for reasons similar to the one previously stated. I apologize if that appeared ungrateful.

I understand the disappointment at a perceived lack of interest – I guess it goes with the territory. Fortunately, when it becomes clear that a post was helpful, it makes all the participation worthwhile.

You do bring up a good point, however. In the process of learning VBA, I’ve seen some very informative programming examples to which I did not make a significant comment. In retrospect, I’d like to thank the authors of those posts (even if they are not aware). Those contributions have all been quite helpful. I’ll try to be more immediate with my gratitude through my continuing studies.

LCE
29th May 2008, 09:42 am
SEANT,

Thanks for your comments on this. This post though wasn't the 1 that bought it to my attention, I have always been aware of the lack of gratitude from members of this board, hence passwording it this time and all apps that I post.
If people are not comfortable downloading my work if they can not view the source then that is fine. I respond to the OP and post and app that will help them acheive what they have requested. I am not spending my time writing apps just for people to strip parts from and re-use. This isn't just me being selfish (ok, maybe a little) but I also have a strong belief that doing this does not help you really learn.

Anyway, rant over now.

Thanks.

spittle
29th May 2008, 09:53 am
I'm still keen if you make any amendments. The first thing my colleague did was try to have a look as he was keen to see how it was produced. I get what both sides are saying, for me I've no clue on VBA and have many other things i'm trying to learn at the moment so it wouldn't be of use to me anyway at the moment.
If a VBA can be created to improve the speed of changing linetypes to the correct one in an effort to quickly fix lineype scales on older drawings, I think it could be very useful for a lot of users. Or certainly those who work within organisations where there arn't a great deal of drawing standards!

Bob Myles
15th Jul 2008, 05:16 pm
Hello, New guy to the forum, using ACAD 2004... We have a client that wants us to send him our structurals for incorporating in his ARCH Set. No prob right! Well there are some issues that I think this script (or similar) will help us out with.
They use a Global Linetype Scale = 48 (so we change the Global setting to 48 and then we make the following linetype, color and LineTypeScale (LTS) changes)
Crosshatch changes to White with LineTypeScale (LTS) to .1
Dashed with LTS of 6 changes to .2
Dashed with LTS of 24 changes to .4
DotDash changes to .4
Dotted changes to Dashed and LTS .3
While I am not asking that someone write the entire code, if it is possible to get a few lines of working code that I can learn from and add to, that would be Great!!
There really doesn't need to be an Interface, as long as i can add to the code, as all I want the users to do is click a button save and send the file...... However I can see that flexibility of a dialog box will make it more apealing to the masses...

I truly appreciate your time,
Bob Myles
Structural Products Corp.