Author Topic: Mid point of a blockref  (Read 20507 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Re: Mid point of a blockref
« Reply #45 on: April 30, 2008, 05:19:51 PM »

Bob

I will need to try it but I am wondering about this part

Code: [Select]
pntLL(0) = ((minExt(0) + maxExt(0)) / 2) - 67.93
      pntLL(1) = (minExt(1) + maxExt(1)) / 2 - 43.04
      pntLL(2) = (minExt(2) + maxExt(2)) / 2
      pntUR(0) = ((minExt(0) + maxExt(0)) / 2) + 67.93
      pntUR(1) = (minExt(1) + maxExt(1)) / 2 + 43.04
      pntUR(2) = (minExt(2) + maxExt(2)) / 2

I'm not sure why you have the trailing numbers? The +/- 's
The reason I say this is because the scale of that template can change as per what I am doing

For example, if I am doing symbols, then the views will be smaller
If I am doing label type symbols, the views will be larger.

I'm sorry, I should have told you that I may scale the template up or down

The views are nothing more then closed polylines

For each boundary
 get the llpnt and the urpnt
 Make the slide
Next boundary

Wouldn't that work?

Let me try the code

Thanks!

Mark

ML

  • Guest
Re: Mid point of a blockref
« Reply #46 on: April 30, 2008, 05:27:38 PM »

Bob

Good try but still not quite right

I think it would be fine to just be prompted for 2 points
llpnt and urpnt

After you pick the points, the slide gets created with all the rest of your code

So, if I have to pick 2 points 75 times, that is still not the end of the world

Mark

Bob Wahr

  • Guest
Re: Mid point of a blockref
« Reply #47 on: April 30, 2008, 05:28:55 PM »
meh.  Knew that was a chance, tried to cheat it because it was less code change.  I'll do it the other way but probably not before tomorrow.

ML

  • Guest
Re: Mid point of a blockref
« Reply #48 on: April 30, 2008, 05:31:24 PM »
Bob

If you incorporated this in

restore, view 3 (respective number), mslide blkref.name

That would do it

You see, I define the boundaries for each view upfront

If you restore each view, then grab the minext and maxext pnts of that boundary, then the slide would get created exactly as inteneded

Or a zoom window of each closed boundary (polyline), that would also do it

Thanks!

Mark

ML

  • Guest
Re: Mid point of a blockref
« Reply #49 on: April 30, 2008, 05:33:10 PM »

LOL

I'm sorry man!

You're doing a great job, you probably just didn't know all of my manual methodologies upfront.

If you nail this the way I am suggesting, then it would work with rectangles as well as named views

It would be very cool

Mark

ML

  • Guest
Re: Mid point of a blockref
« Reply #50 on: April 30, 2008, 05:36:02 PM »

I think that this
Code: [Select]
For each boundary
 get the llpnts and the urpnts
 Make the slide
Next boundary
Would be the best and most flexible method by far.

This would work with closed plines, named views and rectangles...as they are all treted the same, I believe

Mark

Bob Wahr

  • Guest
Re: Mid point of a blockref
« Reply #51 on: April 30, 2008, 05:39:19 PM »
What are your criteria for setting the view size?

ML

  • Guest
Re: Mid point of a blockref
« Reply #52 on: April 30, 2008, 05:46:34 PM »

It is a good old fashion method called eye balling it  :lmao:

Seriously!

Think of each rectangle (view, respectively) as an image in an image tile

So, if you were to do a zoom extents and draw a box, then you would have your first image tile
If the block looks good centered in that box, then you zoom out and array that box as many times as necessary.

I really do think by grabbing the ll and ur points of each boundary would be the most dynamic way to hit it

So, for each rectangle, you are msliding whatever is inside each rectangle

The question then is how do you retreive the block name inside of each rectangle

Man! i don't know that answer

Mark

ML

  • Guest
Re: Mid point of a blockref
« Reply #53 on: April 30, 2008, 05:50:43 PM »

Bob

Let's simplify this

Prompt the user to select the blockref, then you prompt them to pick two points; that is the lower left and upper right points of the closed pline.

After the user selects the blkref, we store that blkref name in a variable, get the points and create the slide using the blkref name

What do you think?

Between the code you did for centering the blocks (bounding box code) and the code I am suggesting here, we would move right through 75 mslides.

Mark

Bob Wahr

  • Guest
Re: Mid point of a blockref
« Reply #54 on: April 30, 2008, 06:10:42 PM »
The question then is how do you retreive the block name inside of each rectangle
That's not hard but I still don't like one click each, much less two.  What about zooming in on the bounding box, then zooming out .9x (or whatever) to give a little buffer?

ML

  • Guest
Re: Mid point of a blockref
« Reply #55 on: April 30, 2008, 06:25:27 PM »

Really?

I like the idea of picking the blockref then the two boundary points.
I guess that can really screw up the works if you miss.

Bob, I need the whole rectangle, point to point.

No zoom involved, unless you do a zoom window on the lower and upper corner of each closed polyline (boundary) then grab the blkref name, then do the mslide.

Think of each corner of the rectangle as a corner in the image tile box.

However the block looks inside the rectangle is exactly how it will look in the image tile.

This is why we scale up or down for different block types

Mark



ML

  • Guest
Re: Mid point of a blockref
« Reply #56 on: April 30, 2008, 06:29:48 PM »

Quote
What about zooming in on the bounding box, then zooming out .9x (or whatever) to give a little buffer?

No buffer necessary

Bob, suing that template that I sent to you, type -view at the command line, then select r for restore, then type in 1.

It will restore view 1. The way you see it there is exactly how I will need the slide to look

Each view is created by defining the boudary, end point to end point

Does that make sense?

Thanks
Mark

ML

  • Guest
Re: Mid point of a blockref
« Reply #57 on: May 01, 2008, 03:26:52 PM »

Hey Bob

I decided to try to write out a script in the debugging window, for now.
If all works out, I may even write it out to an .scr file

The code seems to be working well:
Code: [Select]
Sub WriteScript()

Dim BlkRef As AcadBlockReference
Dim Ent As AcadEntity
Dim NView As AcadView

For Each Ent In ThisDrawing.ModelSpace
 If TypeOf Ent Is AcadBlockReference Then
  Set BlkRef = Ent
  For Each NView In ThisDrawing.Views
   Debug.Print "view" & vbCrLf & "r" & vbCrLf & NView.Name & vbCrLf & "mslide" & vbCrLf & Ent.Name
  Next NView
 End If
Next Ent

End Sub
Except that I have 73 named views and it is only writing out 34 to 73

Any idea why?

Thanks!
Mark

ML

  • Guest
Re: Mid point of a blockref
« Reply #58 on: May 01, 2008, 03:40:38 PM »

OK

I've answered my own question  :laugh:

Evidentally, the debugging window has a limitation to how many lines can be written to it

I just threw together this code real quick

Code: [Select]
Sub TestCode()

Dim BlkRef As AcadBlockReference
Dim Ent As AcadEntity
Dim NView As AcadView
Dim FSO, MyFile

Set FSO = CreateObject("Scripting.FileSystemObject")

Set MyFile = FSO.CreateTextFile("c:\test.scr", True)

For Each Ent In ThisDrawing.ModelSpace
 If TypeOf Ent Is AcadBlockReference Then
  Set BlkRef = Ent
  For Each NView In ThisDrawing.Views
   MyFile.WriteLine "view" & vbCrLf & "r" & vbCrLf & NView.Name & vbCrLf & "mslide" & vbCrLf & Ent.Name
  Next NView
 End If
Next Ent

MyFile.Close

End Sub

And it successfully wrote out all of the info to a .scr file

That is pretty cool

The only thing I am still unsure about is why some of the numbers (named view names) are not all in order in the scr file?

Also, I need to make sure that each block is getting assigned to the right named view in the script.

Any help here would be appreciated

Thanks
Mark