PDA

View Full Version : xref auto scale by using dimscale



cadd4la
2005-05-17, 08:15 PM
Hi everyone,

I am looking for a VBA that when you xref a drawing, it reads the dimscale of the drawing that is going to be XREF into the drawing.

Background.

For my detail sheets I XREF in the details one at a time and scale them manually enter in a factor of taking the scale of the detail (not the Dimscale) and dividing it by 12.

examples:

3/4"=1'-0" wood be 0.75/12 = 0.0625 is the insert scale
1"=1'-0" would be 1/12 = 0.083333333 is the insert scale

I would like when xrefing each of the details that the scale be done automatically or if this can't be done, I would like a pulldown menu with a list of scales that has the factor for that detail scale.

:confused: One problem I see, how do you take the dimscale of 16 (for 3/4" =1'-0") and get the insert scale of 0.0625?

Thanks,

Kyle C.

mtuersley
2005-05-18, 05:48 AM
I am looking for a VBA that when you xref a drawing, it reads the dimscale of the drawing that is going to be XREF into the drawing.
<snip>
...and scale them manually enter in a factor of taking the scale of the detail (not the Dimscale) and dividing it by 12.

Which is it? DIMSCALE value or not? You're contradicting yourself. If it's dimscale, then the XREF drawing can be pre-opened in DBX and have its dimscale value read - assuming that the dimscale is always correct. If its not dimscale, how would a program "know" what scale it was drawn at? Anything in the detail that gives that information?



:confused: One problem I see, how do you take the dimscale of 16 (for 3/4" =1'-0") and get the insert scale of 0.0625?

You take the reciprocal of the value so 1/16. How can you be confused if you do this manually???

cadd4la
2005-05-18, 04:00 PM
mtuersley,


Which is it? DIMSCALE value or not? You're contradicting yourself. If it's dimscale, then the XREF drawing can be pre-opened in DBX and have its dimscale value read - assuming that the dimscale is always correct.I would like it to use the DIMSCALE



Anything in the detail that gives that information?

The only other thing is the blocks that I use in the details are scaled to that detail's scale factor.



You take the reciprocal of the value so 1/16. How can you be confused if you do this manually???:Oops: Thanks for putting me in my place.

mtuersley
2005-05-18, 04:32 PM
Explode the blocks then you can use the DBX method, or rename them to a unique name specific to each detail. In general, you should never use blocks in details if you intend to insert the details into other drawings.

FWIW it sounds like you'd be further ahead by editing all of your details to be 1=1 then you can accomplish the insert w/o issue.

cadd4la
2005-05-18, 04:54 PM
mtuersley,

:banghead: How are you helping?




Explode the blocks then you can use the DBX method, or rename them to a unique name specific to each detail. In general, you should never use blocks in details if you intend to insert the details into other drawings. :???: What are you saying?




FWIW it sounds like you'd be further ahead by editing all of your details to be 1=1 then you can accomplish the insert w/o issue. The blocks that are in the details are the callout number bubbles, the detail is drawn 1=1 then when the detail is xrefed into the detail sheet it's scaled by 1/x

mtuersley
2005-05-18, 05:06 PM
I can't help if you don't accurately describe your intent and existing environment. For example, this is the first you mentioned that your blocks are 1=1, which means you don't need their dimscale at all. All that you need is the insert xref example in the vba help file and you replace the example's scale factor with your own - which would be the same calc you're doing manually.

mtuersley
2005-05-18, 05:13 PM
Here is the example minus the ListBlocks subfunction:

Sub Ch10_AttachingExternalReference()
On Error GoTo ERRORHANDLER
Dim InsertPoint(0 To 2) As Double
Dim insertedBlock As AcadExternalReference
Dim tempBlock As AcadBlock
Dim msg As String, PathName As String

' Define external reference to be inserted
InsertPoint(0) = 1
InsertPoint(1) = 1
InsertPoint(2) = 0
PathName = "C:/Program Files/AutoCAD 2005/sample/City map.dwg"

' Add the external reference to the drawing
Set insertedBlock = ThisDrawing.ModelSpace. _
AttachExternalReference(PathName, "XREF_IMAGE", _
InsertPoint, 1, 1, 1, 0, False)
ZoomAll

Exit Sub

ERRORHANDLER:
MsgBox Err.Description
End Sub

In this line:


' Add the external reference to the drawing
Set insertedBlock = ThisDrawing.ModelSpace. _
AttachExternalReference(PathName, "XREF_IMAGE", _
InsertPoint, 1, 1, 1, 0, False)


replace the 1,1,1,0 with yourCalcedDimscale,yourCalcedDimscale,1,0

cadd4la
2005-05-18, 07:56 PM
mtuersley,


I can't help if you don't accurately describe your intent and existing environment. For example, this is the first you mentioned that your blocks are 1=1, which means you don't need their dimscale at all. All that you need is the insert xref example in the vba help file and you replace the example's scale factor with your own - which would be the same calc you're doing manually.
What block are you talking about? The only blocks that are in the drawing are the callout number bubbles that have att text in them and that is scaled to the scale factor of the detail - for example a detail that the final output is going to be 3/4"=1'-0" the block is scaled 16 times. the detail is drawn to 1"=1" and the dimscale is set to 16.

I have upload a file that shows a typ. detail draw 1 to 1 in model space the dimscale is set to 16, the sq w/ the numbers are the only blocks in the drawing and they are scaled by 16. the purple text is for me to remember the scale of the detail and is on a nonprint layer.

now, I would open the detail drawing file in layout space and xref this detail in at 1/16

back to me original request - I would like a VBA program to read the dimscale so I don't have to remember the scale of that detail that I have in my detail library and was drawn six month ago.

Kyle C.

cadd4la
2005-05-25, 01:22 AM
Hi everyone,

I am still looking for help with my questions

Thanks,

Kyle C.

RobertB
2005-05-25, 04:41 PM
Since you cannot examine system variables in ObjectDBX, you need to store the scale factor in the detail in an Dictionary/XRecord, or examine the scale factor for a consistent object (title-line block) in the detail.

Once you have a stored scale factor, you can use ObjectDBX to open the original detail to retrieve the data.

cadd4la
2005-05-25, 10:10 PM
Robert,

Sorry, your talking beyond what I know about VBA


you need to store the scale factor in the detail in an Dictionary/XRecord, or examine the scale factor for a consistent object (title-line block) in the detail
Are talking about the callout number bubbles blocks (that has att text in them) that are in the drawing, they are either inserted to the scale factor or 1 to 1 of the details don't have to have a scale to it?

thanks,

Kyle C.

chatcher
2005-05-26, 12:23 PM
Robert is suggesting that you store the scale factor in the xref'd drawing so you would be able to access it using objectDbx.

You have two options since you cannot read system variables from either xref'd drawings or objectdbx.

1. You open the xref'd drawing and examine the dimscale before xrefing it. This would be the easiest from a coding standpoint but performance will be an issue. It's gonna be slow.
2. Inside the Xref drawing you create a block with the dimscale in it that you could read from objectdbx. This would be very fast but there are two drawbacks: The code is more complex and if you ever change the dimscale of the drawing without updaing the block - garbage.

I just thought of another option but it would be more complex than the second even..

RobertB
2005-05-31, 10:01 PM
Robert is suggesting that you store the scale factor in the xref'd drawing so you would be able to access it using objectDbx.
...
I just thought of another option but it would be more complex than the second even..Our system is setup so that whenever a detail drawing is opened, the scale factor is determined and stored in an XRecord. From that point out, whenever we run our Detail Insert routine, that XRecord is read from the source detail drawing and the scale factor is then known. Took some initial effort, but works great.

chatcher
2005-06-01, 12:52 PM
I like that better than the block attribute. No nosy users hosing your factor...

So, you must have control of your environment, and using events? nice.

If I had TOTAL control of the AutoCAD session, I might consider adding the info in binary format to the end of the dwg file on close. That way you could read it without AutoCAD or ObjectDBX and it would be very fast. The only drawback would be if someone opened and saved the file without the app capturing the close event - no data added..

RobertB
2005-06-01, 03:41 PM
ObjectDBX is plenty fast. I don't think there is much advantage to glomming binary data to the end of the actual .dwg file.

richard.binning
2005-06-02, 03:11 AM
Seems to me Kyle stated that his "column" bubble blocks get inserted at the scale of the detail drawing. If that is the case, then it should be easy to open the file using DBX, iterate the spaces to find the block insertion and read its scale. Then close the file and xref it into the current drawing using your pre-read scale factor.

RLB

L.J.Oosterbaan
2005-06-06, 09:18 PM
Why not use Open Design's ODX ? Before xref-ing the drawing, scan it for the Dimscale,
and bingo...
see www.opendesign.com
i know this sounds as blasfemie, but i've been poundering around the AutoCad-dll's you can reference in VBA, but have no luck in finding anything that can do a similar job,
only with open drawings.
It's pretty weird that one cannot access unopened drawings with a full install of Autocad,
but needs to refert to stuff like DToolsX-DWG from www.cadology.com, which is based on
mentioned ODX. Especially because of the nowadays drawings, with a lot of different layouts, it would be nice if one could browse thru these drawing, looking for a particular layout (which is essentially the real product if you're not into CAM) without having to open a few hundred drawings. Ofcourse one could implement a database and fill it each time you've got a drawing open, but in fact the drawing is a kind of database table in a file structured database of directories and drives....

Getting better informed about the available and installed dll's/ocx's: is that an idea for a discussion thread?

cadd4la
2005-06-10, 12:09 AM
Hi Robert,

It sounds like you have the setup that I am looking for, could you go into more detail about it and I don't know what XRecord is or used for, could you give me more info on that.


Our system is setup so that whenever a detail drawing is opened, the scale factor is determined and stored in an XRecord. From that point out, whenever we run our Detail Insert routine, that XRecord is read from the source detail drawing and the scale factor is then known. Took some initial effort, but works great.
Could you Also tell me more about your Detail Insert routine .

Thanks,

Kyle C.

RobertB
2005-06-12, 10:05 PM
XRecords are non-graphical information stored in Dictionaries which is also non-graphical. I earlier described how the detail insert routine worked. I have far too many other projects going on to describe in full detail, which I presume means you also want my code.

cadd4la
2005-06-14, 12:15 AM
Robert,

You make it sound so evil :veryevil:


XRecords are non-graphical information stored in Dictionaries which is also non-graphical. I earlier described how the detail insert routine worked. I have far too many other projects going on to describe in full detail, which I presume means you also want my code.
But seriously, I would like to have your help or somebody's in writing or showing me what is needed to have the program to do what I need it to do, and if that takes exchanging emails over days or weeks. At least I get a better understand of VBA.

Kyle C.

RobertB
2005-06-14, 04:10 AM
You make it sound so evil :veryevil:

But seriously, I would like to have your help or somebody's in writing or showing me what is needed to have the program to do what I need it to do, and if that takes exchanging emails over days or weeks. At least I get a better understand of VBA.
Sorry. I figured it would sound that way, but you can't really suger-coat it much, can you?

Search prior posts for Dictionary/XRecord code. I'm sure I've posted some in the past.