Author Topic: Insert Blocks and INSUNITS  (Read 5157 times)

0 Members and 1 Guest are viewing this topic.

Bennos

  • Mosquito
  • Posts: 8
Insert Blocks and INSUNITS
« on: May 01, 2007, 08:03:21 PM »
Hello,

I'm currently in the process of creating a class for BlockTableRecords, with in this class i have created an Insert function. Inserting blocks with known scales is not a problem, but i was after was some more information regarding to how autocad deals with the INSUNITS system variable. As when you do a manual insert, it rescales the block to suit the current INSUNITS variable. How is this conversion done, and how would i go about replicating it.

Thanks in advance

Bennos

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Insert Blocks and INSUNITS
« Reply #1 on: May 01, 2007, 08:49:38 PM »
You may also want to have a look at the system variables INSUNITSDEFSOURCE and INSUNITSDEFTARGET

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Bennos

  • Mosquito
  • Posts: 8
Re: Insert Blocks and INSUNITS
« Reply #2 on: May 01, 2007, 09:20:50 PM »
You may also want to have a look at the system variables INSUNITSDEFSOURCE and INSUNITSDEFTARGET



Thanks Kerry, will check it out.

Found the problem, you need to set the blocktablerecords units value after you add it to the block table.
« Last Edit: May 01, 2007, 09:38:55 PM by Bennos »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Insert Blocks and INSUNITS
« Reply #3 on: May 01, 2007, 09:38:47 PM »
I've just had a scan of the Managed Class docs

Autodesk.AutoCAD.DatabaseServices.BlockTableRecord Properties
has a Property .Units

You may be able to make use of this.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Bennos

  • Mosquito
  • Posts: 8
Re: Insert Blocks and INSUNITS
« Reply #4 on: May 01, 2007, 10:20:03 PM »
I've just had a scan of the Managed Class docs

Autodesk.AutoCAD.DatabaseServices.BlockTableRecord Properties
has a Property .Units

You may be able to make use of this.



Thanks for the tip, i have the blocktablerecord units property to the insunits form the source database.

Have another problem, how does autocad determine the scale between millimeters and meters, ie 0.001 and feet to millimeters i.e 304.8.
I need to scale my blockreference to these scales for them to insert at the scaled size.





Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Insert Blocks and INSUNITS
« Reply #5 on: May 01, 2007, 10:35:22 PM »
If I understand the question ...

Some of the more common INSUNITS <UnitsValue Field> settings include:
0 = Unspecified (No units)
1 = Inches
2 = Feet
4 = Millimeters
6 = Meters

Would you just factor according to the setting ?

Source 4 to Target 6  is * 0.001
6 to 4 is * 1000
4 to 1 is * 0.0393700787402...
.. etc
( OR the other way around :-))


« Last Edit: May 01, 2007, 11:07:52 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Bennos

  • Mosquito
  • Posts: 8
Re: Insert Blocks and INSUNITS
« Reply #6 on: May 01, 2007, 11:25:04 PM »
If I understand the question ...

Some of the more common INSUNITS <UnitsValue Field> settings include:
0 = Unspecified (No units)
1 = Inches
2 = Feet
4 = Millimeters
6 = Meters

Would you just factor according to the setting ?

Source 4 to Target 6  is * 0.001
6 to 4 is * 1000
4 to 1 is * 0.0393700787402...
.. etc
( OR the other way around :-))




Good point, will probably go with your option. Thanks for your help.

Bennos

  • Mosquito
  • Posts: 8
Re: Insert Blocks and INSUNITS
« Reply #7 on: May 02, 2007, 01:16:26 AM »
If I understand the question ...

Some of the more common INSUNITS <UnitsValue Field> settings include:
0 = Unspecified (No units)
1 = Inches
2 = Feet
4 = Millimeters
6 = Meters

Would you just factor according to the setting ?

Source 4 to Target 6  is * 0.001
6 to 4 is * 1000
4 to 1 is * 0.0393700787402...
.. etc
( OR the other way around :-))




Good point, will probably go with your option. Thanks for your help.


Found the DatabaseServices.UnitConverter.GetConversionFactor
This does the convertion for all the unit types.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Insert Blocks and INSUNITS
« Reply #8 on: May 02, 2007, 01:57:37 AM »
Good find , that's comforting to hear, I think.  ... persistance IS rewarded. !! 

:-)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.