View Full Version : Guidance required please!
paul.fds
2009-04-02, 07:58 PM
The following code inserts an xref and then a polyline block on top of the xref both at 0,0.
The xref changes layer, the polyline is offset and used as a cutpath for xclip. I have a script to open a new drawing and then runs the code, but as you experts can see it is a very crude way of doing it. Basically it is just a list of commands and i'm sure it's not the correct way to write code. So! would you be kind enough to re-write the code the correct way or explain why it's wrong.
How would you select the xref without placing it on it's own layer?
How would you select the polyline without placing it on it's own layer?
How would you offset?
Any help appreciated
Paul
(defun c:Test ()
(command "-xref" "Attach" "testref.dwg" "0,0" "" "" "")
(command "chprop" "l" "" "la" "xrefobj" "")
(command "_.insert" "*poly" "0,0" "" "" "")
(command "zoom" "extents" "")
(setq odist 400)
(setq pp (ssget "_X" '((8 . "boundary"))))
(command "offset" odist pp "0,0" "")
(command "chprop" "l" "" "la" "cutpath" "")
(setq cp (ssget "_X" '((8 . "cutpath"))))
(setq ss (ssget "_X" '((8 . "xrefobj"))))
(command "_.xclip" ss "" "_n" "_s" cp "")
(setq pp (ssget "_X" '((8 . "boundary"))))
(command "erase" pp "")
)
rkmcswain
2009-04-02, 10:07 PM
How would you select the xref without placing it on it's own layer?
How would you select the polyline without placing it on it's own layer?
One way to do that is to capture the entity name right after you create it by using (entlast).
If you are trying to select a particular entity that is already in the drawing, then you either have to physically select it, or know *something* unique about it, like the handle then use (handent).
paul.fds
2009-04-04, 05:43 PM
Hi 'RK'
thanks for the reply, i've managed to put a couple of 'entlasts' into the code and all's well so far.
Next question!....once the routine has run and i have a new drawing with the xref xclipped how do i add in a 'save as' 'Drawing Name' and 'Destination folder' ?
Paul
rkmcswain
2009-04-06, 12:48 PM
One way....
(command "._SAVEAS" "" "C:\\MyPath\\MySubdirectory\\MyDrawing.dwg")
paul.fds
2009-04-06, 02:26 PM
Thank you, I think you can probably see where this is going!
My idea is this, I’m wanting to create a drawing for each room. Some how I need to select the polylines one at a time and I thought the way to do it would be to add a Block within each polyline containing one attribute (room number e.g. RM01, RM02 etc)
and then do the following….
Open new drawing
Insert Xref (floorplan)
Insert Polyline drawing
Select first polyline (finds polyline using attribute RM01)
Offset Polyline
Xclip
Save as RM01.dwg (gets drawing name from attribute ‘RM01’)
Open new drawing
Insert Xref (floorplan)
Insert Polyline drawing
Select second polyline (finds polyline using attribute RM02)
Offset Polyline
Xclip
Save as RM02.dwg (gets drawing name from attribute ‘RM02’)
and so on….
What do you think ? Is this the right way to do this or would you do it another way?
Do I write the code by replocating the order above?
I’m not an expert but i’m wanting to attempt to write the code myself and thought there’s only one way to learn……”in at the deep end”
howardjosh
2009-04-07, 10:04 PM
first of all I think you are out of you mind:)
that just sounds like a horrible way to manage a project, but then I don't know the context/scope of your work, and I am all for helping someone who wants to learn...
I honestly could not tell you if this would work, but... here is a thought I would play with in your situation.
first I would write a command that would help me drop needed xdata on an object.. Such as drawing name, path, title, ect. I have not worked with xdata a whole lot and am very good at string manipulation... So I would probably leave a string on the dxf code group 1000 (i think) that could easily be turned into a list with the (read) function. Probably not the best, method, but I haven't delved into xdata much.
Next I open my arch background. Make a no plot layer and polyline trace the borders of the rooms I am wanting to make individual drawings of. Use my command to drop needed data on each room polyline. Run the filter command and select all the polylines move them to an elevation of 120. Save the drawing...
now that all the information is there... Several things come to mind. If this background has little chance of changing you could save it as a dwt and make no files at all, and anytime you start a new room you could run a command that autoxclips and saves the drawing based on your xdata (single click).
Another option is to just use it as an xref... with xclip locations already setup. Using the following lisp you can copy an object out of an xref (or any other block) into your current drawing.
(entmake(entget(car(nentsel))))
from there its just (entlast) to get this new object as the target for your xclip command.
there's really a ton of ways and things you could do.. These are just some ideas. You could take it as far as a "set it and forget it" separate namespace vlx command to build them all for you, but I wouldn't want to touch that from lisp..... Just remember the whole point of lisp is to customize in such a way that it will save you time in the long run, and sometimes it won't save you any time at all, but it will on the next project having already written the code. I learned a ton about lisp working on a large project I eventually deleted. So it was pointless, but I've gained the abilities one of my peers took many years to learn, and in most cases (the majority of people) will NEVER learn.
anyway there's my 2 cents... its kind of dated but here is a decent dxf reference
http://www.autodesk.com/techpubs/autocad/acad2000/dxf/
paul.fds
2009-04-08, 10:50 AM
Howardjosh,
thanks for your honesty it is appreciated. Perhaps i am getting a little carried away but when you've been drawing individual rooms and elevations the traditional way you find youself craving some form of automation before your brain goes numb. I have a couple of little routines which help so i'll just stick with those for now, thanks for your post and i'll keep in mind your ideas.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.