PDA

View Full Version : Need to change linetypes to a non bylayer linetype


eleonard
2005-10-11, 04:51 PM
I have been trying to convince the cad manager to change the way we draw topo drawings, but I don't think it is going to work. We recive drawings from survey that were created with an autoline program. This program places all our topo lines on individule layers with everything set as the bylayer. (which if i got my way would stay that way). Then once we get that we have to change all lines off of they linetype bylayer to the desired linetype and place all lines on one layer.
I am trying to figure out how to do this in a lisp routine. My abilities are not that great when it comes to programing so i am hopeing that someone can help me.

Thanks

Opie
2005-10-11, 04:57 PM
I'm not going to second guess your CAD manager. He/She probably has a reason of why it needs to be that way. I also don't agree with that decision.

What are the steps that you do now to accomplish this task? Do you select all of the lines on a particular layer and then change the linetypes for those entities on that layer? Wash, rinse and repeat for the remaining layers?

eleonard
2005-10-11, 06:02 PM
Yes that seems to be the way we do things.
I think the reasoning they want to keep things all on one layer is because someone at one point didn't pay attention to what they were doing and some layers were turned off. It is a royal pain to do things the way we do, but you do what you are told. I am just looking for a way to speed up the process because we have one person that will take what should be a 2 hour job and turn it into a 6 hour job.

Opie
2005-10-11, 06:05 PM
I understand on the stretching out of a job. Someone here will stretch out some dwgs out to about a week or longer.

To help with the steps for a lisp, one needs to write out a list of steps. So what are the steps that you do now to accomplish this task?

eleonard
2005-10-11, 07:09 PM
Well when i actually work on a topo drawing, I will start by isolating the layer i want to start with and I will select all the lines on that layer and change the properties on it. Then I move onto the next layer and do the samething untill all the layers have been changed. Then I isolate all the symbols and place them on yet another layer for example all our lines are on a layer named 'Topo' and all our symbols are placed on a layer named 'Topo-20' to represent that the blocks are at a 20 scale.

Does that make sense?

jwanstaett
2005-10-11, 09:06 PM
If the line type of layer is set to the line type you need. you can select all the lines using lisp and then go Thur each object and change the line type to the line type of the layer it is on and then change the layer that you put all the line on.

load this code use command chlinetype will change all lines in the drawing so the linetype of the line is set to the linetype of the layer it is on. and the layer will change to 0. you can change the layer by change the code.


(vl-load-com);load Vla fucntions

(defun c:chLineType()
(setq acadObject (vlax-get-acad-object));get acadobject
(setq acadDocument (vla-get-ActiveDocument acadObject));get document object
(setq layers (vla-get-layers acadDocument));get layres
(setq lines (ssget "x" (list (cons 0 "line"))));Select all lines
(setq thisline (ssname lines 0));Set thisline to first line
(while (/= nil thisline);loop till there on lines in the selection set
(setq obj (vlax-ename->vla-object thisline));change the line to a vla object
(setq mylayer (VLA-ITEM layers (vla-get-layer obj) ));Get the layer the object is on
(vla-PUT-LINETYPE obj(vla-get-linetype mylayer));set the line to the line type of the layer
(vla-put-layer obj "0");Change to layer 0 change "0" to the layer you use
(setq lines (ssdel thisline lines));Remove the Line form the selectition set
(setq thisline (ssname lines 0));get next line
);end while
);end defun

eleonard
2005-10-11, 10:23 PM
I gave that a try and if i open up my drawing that contains all of our standard layers & linetypes, and it worked just fine. So then i opened up one of our topo drawings that we get from our survey crew and i try it again and this is what i get:

; error: bad argument type: lselsetp nil

Any ideas?

David.Hoole
2005-10-12, 11:08 AM
As another way of approaching this issue, how about some code that would ensure that all the layer states are correct? This could run on Open or Save.

This seems like a better option than making the drawings really, really unfriendly by putting everything on one layer with disrcrete properties.

eleonard
2005-10-12, 03:31 PM
As another way of approaching this issue, how about some code that would ensure that all the layer states are correct? This could run on Open or Save.

This seems like a better option than making the drawings really, really unfriendly by putting everything on one layer with disrcrete properties.

I would hope that if I could provide something that would ensure this the cad manager might go for it. I work with a bunch of people who have been doing this for years, and when I say years, they were here before computers took over.

How would something like this actually work? I wouldn't know where to even begin in writing a code that would do this. Keep in mind that this topo drawing is alway xref'd into our base drawing and then the base dwg is xref'd into our individule sheets.

Opie
2005-10-12, 03:43 PM
I would hope that if I could provide something that would ensure this the cad manager might go for it. I work with a bunch of people who have been doing this for years, and when I say years, they were here before computers took over.

How would something like this actually work? I wouldn't know where to even begin in writing a code that would do this. Keep in mind that this topo drawing is alway xref'd into our base drawing and then the base dwg is xref'd into our individule sheets.
What David is referring to would be using REACTORS. You would first need your routine to accomplish setting the layer state. Then you would need to create a reactor which would be triggered on Open or Save, which would run your layer state routine. It's not a difficult routine, but you have to make sure the layer state is in the drawing or you will need to import the state into the drawing.

I would highly recommend to you and your CAD Manager, to allow your entities in your drawings to be set bylayer. This will allow you to control how the entities are plotted when you xref them into another drawing. If you keep the entities set to a specific color other than bylayer, you lose that ability for controlling how things are plotted.

jwanstaett
2005-10-12, 03:45 PM
I gave that a try and if i open up my drawing that contains all of our standard layers & linetypes, and it worked just fine. So then i opened up one of our topo drawings that we get from our survey crew and i try it again and this is what i get:

; error: bad argument type: lselsetp nil

Any ideas?this error is do to no line in the drawing check to see if the topo drawing are using lines and are not plines or lines in block or xrefs

note: the layer you are move the lines to need to be in the drawing or you get this error
; error: Automation Error. Key not found

jwanstaett
2005-10-12, 03:53 PM
As another way of approaching this issue, how about some code that would ensure that all the layer states are correct? This could run on Open or Save.

This seems like a better option than making the drawings really, really unfriendly by putting everything on one layer with disrcrete properties.
This is a command in AutoCAD.
It the Layer command import layer state
You first use a drawing that have all the layer set the way you need them and you export the layer state. Then all you need to do is import the layer state and it set all the layer the way you need then.

Opie
2005-10-12, 05:06 PM
This is a command in AutoCAD.
It the Layer command import layer state
You first use a drawing that have all the layer set the way you need them and you export the layer state. Then all you need to do is import the layer state and it set all the layer the way you need then.
But then there is no guarantu that the user will apply that layer state at the end of the drawing. It would be nice if CAD managers could trust the users to do those things, but sometimes you just have to make the computer do some of the thinking.

eleonard
2005-10-12, 08:03 PM
Thank you for all the wonderful suggestions. I have to sit down sometime when we are not in a crunch and have a serious talk with the current CAD manager.
I will look into all of these things and hopefully we can come up with a time saving solution.

David.Hoole
2005-10-13, 11:22 AM
Richard

I was thinking of 2 options:

Either reactors, which aren't the easiest things to programme effectively.

Or redefining the Save, Saveas, Qsave, and Plot commands to first run some code to set the layer states. Some hard labour involved in setting up, but probably easier than reactors.

Personally, I'd go to any lengths to avoid the original scenario.

eleonard
2005-10-13, 03:37 PM
So now my big question is........ how do i convince the Cad Manager that what we are currently doing (changing the linetype's off the bylayer) is a bad thing and a waste of time. And that with people paying a little more attention we can keep things just the way they are given to us?

Opie
2005-10-13, 03:59 PM
David,

The reactors are not that difficult to write. I have one on my save event to change the case of layer names. When I started with the routine, I used the open event but it would change the dwg database and require a save everytime. I then changed it to the save routine and no problems have occurred since.

Opie
2005-10-13, 04:03 PM
So now my big question is........ how do i convince the Cad Manager that what we are currently doing (changing the linetype's off the bylayer) is a bad thing and a waste of time. And that with people paying a little more attention we can keep things just the way they are given to us?
eleonard (Sorry, I don't know your real name)

You have to convince the CAD Manager that his way is incorrect. That question can be tough.

You will need to point out the benefits of not changing the ltype/color of entities. Some benefits would be that the need to change all of those entities will save time when dwgs need to be reused on future projects. If using xrefs, the lineweights maybe to thick/thin for the dwg using the xref.

Good Luck on your quest.

eleonard
2005-10-13, 08:06 PM
Thanks again. I feel I have a tough battle ahead of me. But maybe with other's imput with in the office I might be able to convince him to change.

Thanks
Emily