Author Topic: help with my code  (Read 4918 times)

0 Members and 1 Guest are viewing this topic.

sbattina

  • Guest
help with my code
« on: March 17, 2004, 03:47:49 PM »
Hi guys:

I am providing a link to my code:

http://www.public.asu.edu/~sbattina/Thesis_1/


It also has a .dwg file of a contoured site which Daron gave me. It sort of draws a tree of 3d cubes over a site. But what I need to do now is to change the elevation  each of these cubes to the corresponding contourline going on top or bottom of each of them. And I need to do this in a loop..not interactively.  I tried drawing an xline from each of these cubes and then tried to get an interseting point to the contourlines. But not all of them intersect. I really dont know how I could apply the nearest point of the line from a line........

I think you will understand better if you look at the code. I feel really stuck...someone help me.

gimme options....suggestions...anything :?

daron

  • Guest
Re: help with my code
« Reply #1 on: March 17, 2004, 04:17:34 PM »
Quote from: sbattina
I feel really stuck up...


Subhadha, I think you mean stuck. Stuck up is something totally different. :lol:

sbattina

  • Guest
help with my code
« Reply #2 on: March 17, 2004, 04:18:55 PM »
heheheheh...... :lol:
yah thats what I mean........yikes! I am going to edit that!! :wink:
did you look into the code...

daron

  • Guest
help with my code
« Reply #3 on: March 17, 2004, 04:22:01 PM »
No, I haven't. That seems like something that Keith, Trev or Hendie might be better able to figure out. I'll look at it, but right now I've got to get back to work.

TR

  • Guest
help with my code
« Reply #4 on: March 17, 2004, 07:05:28 PM »
Can you post the .bas or .cls files instead of the .dvb? I'm on linux and I don't have AutoCAD installed.  :oops:

sbattina

  • Guest
help with my code
« Reply #5 on: March 18, 2004, 12:20:28 AM »
im sorry tim. I cant do that tonight & tommorow. I wont be on Campus tommorow :o(... Shall do it first thing on Friday. :o|

Trev

  • Guest
help with my code
« Reply #6 on: March 18, 2004, 11:12:40 AM »
I'm not quite sure I understand your objective.
Correct me if I'm wrong.
Would you like to place the tree at the elevation of the nearest contour line to the base of the tree?
(this method would have to search the dwg for contour lines (eg: filtering for polylines on a particular layer) compare co-ordinates  then select the nearest to obtain the elevation height. (quite complex)
Or would you like to select a contour line to obtain the elevation height to place the tree. This would take 2 selections 1 for the tree location the 2nd the contour line. (much easier)

One suggestion (maybe I don't know your dwg process) You use your vba program to open your drawing, wouldn't it be more likely that you would all ready have your drawing open?
If thats a normal thing to do then you may wish to add a filter to your open file dialog to only show dwg files.



Quote
but right now I've got to get back to work.

Yeah get back to work ya git!  :P
Meanwhile I'm going to get some sleep (it's 3am here.   :horror:  :crazy: )

sbattina

  • Guest
help with my code
« Reply #7 on: March 18, 2004, 11:50:23 AM »
yes Trev,
It is the "quite complex" one that Im trying to do. I have to make the centers of the boxes get elevated to the corresponding contour line.
Another option would be to change the entire site into a surface..i dont know how the hell thats going to happen.
But I am quite surprised  you understood what I mean...I told this to my friend here and she is blinking...hehe

everyone who has understood what I am talking about....jump right in..

i did look into the option of having the drawing open before hand. Thats how I started off. But I switched to this because I could use this on other drawing files too....

Trev

  • Guest
help with my code
« Reply #8 on: March 18, 2004, 07:00:00 PM »
Quote
did look into the option of having the drawing open before hand. Thats how I started off. But I switched to this because I could use this on other drawing files too....

If you use it on many files, what I would probably do is to create a toolbar/menu option so after opening the drawing you simply select the toolbar it will load your program & run it on the current drawing.
Thats just an option though.
I'll have a bit of a look to see if I can do a search for closest contour point, if that can be done on a  drawing without taking a long time in the search process it is a good option. However the bigger the drawing the longer it would take (particularly with polylines) I'll see what I can do.

Anonymous

  • Guest
help with my code
« Reply #9 on: March 18, 2004, 07:39:34 PM »
alrighty.........
you mean like an array  of contours and then it would search for the closest.
hmmm...closest? nearest X or Y. I am going to try and work on that a bit ....it sounds like a great idea.
but yah..I guess it would take a while to search ...


Thanks a ton
Quote
I'll have a bit of a look to see if I can do a search for closest contour point, if that can be done on a drawing without taking a long time in the search process it is a good option.

Trev

  • Guest
help with my code
« Reply #10 on: March 19, 2004, 05:58:39 AM »
I've got a good start on it and in fact the search does not take very long at all.
Rather than search the whole dwg & comparing entities to the selected point, I am using a method that searches from the selected point creating a selection set at a set distance & using a loop, if nothing found increase the area until an entity is found. This works well & so far is quick. I will however have to add a test when & if more than one entity is found then compare them to select the closest.
Once an entity is selected it's all down hill from there, obtain the z co-ordinate reset your insert point to the elevation required (z co-ordinate) & create your tree object.

daron

  • Guest
help with my code
« Reply #11 on: March 19, 2004, 08:14:01 AM »
Just don't do all the work for her, Trev. I believe this is part of her thesis for school.

sbattina

  • Guest
help with my code
« Reply #12 on: March 22, 2004, 02:10:38 PM »
Im using the code below:

Thsi one worked for just one box and at ceratain conditions

Option Explicit

Public Sub LandLW_inter()

Dim myline As AcadLine
Dim mysel As AcadSelectionSet
Dim selsets As AcadSelectionSets
Dim mypl As AcadLWPolyline
Dim ptst(0 To 2) As Double
Dim ptend(0 To 2) As Double
Dim FilterType(0 To 0) As Integer
Dim FilterData(0 To 0) As Variant
Dim varIntPnts As Variant
Dim cnt As Integer
Dim i As Integer
cnt = 0


Set selsets = ThisDrawing.SelectionSets

' for one block
'points that make up the edge of a house
ptst(0) = 742: ptst(1) = 1029: ptst(2) = 0
ptend(0) = 769: ptend(1) = 1058: ptend(2) = 0
'draw the line for effect
Set myline = ThisDrawing.ModelSpace.AddLine(ptst, ptend)
myline.Color = acRed

For Each mysel In selsets
    If mysel.Name = "mine" Then
        mysel.Delete
        Exit For
    End If
Next mysel

Set mysel = ThisDrawing.SelectionSets.Add("mine")

FilterType(0) = 0: FilterData(0) = "LWPolyline" ' filter on type - lwpolylines
mysel.Select acSelectionSetCrossing, ptst, ptend, FilterType, FilterData
'selects everything crossing the bounding box of our line
'filters out everything but lwpolyline

Debug.Print "Intersects with " & mysel.Count & " lwpolylines"

For Each mypl In mysel
    cnt = cnt + 1
    Debug.Print " Intersection : " & cnt & " with Contour " & mypl.Elevation
    ptst(2) = mypl.Elevation: ptend(2) = mypl.Elevation
   
    'draw the line for effect - don't really need this
   ' Set myline = ThisDrawing.ModelSpace.AddLine(ptst, ptend)
    'myline.Color = acRed
   
    varIntPnts = myline.IntersectWith(mypl, acExtendNone)
           
    For i = 0 To UBound(varIntPnts)
        Debug.Print varIntPnts(i)
    Next i
Next mypl

End Sub





Quote
Just don't do all the work for her, Trev. I believe this is part of her thesis for school.


Daron ..Dont plant horrible ideas like that in Trev's  head :P . hehhee
This is only the begining .. there's atleast 95% more for him......or anybody who wants to work on this  :twisted: