.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Position a Block in Paperspace

14 REPLIES 14
SOLVED
Reply
Message 1 of 15
vince1327
764 Views, 14 Replies

Position a Block in Paperspace

Hey Everyone,

 

I've worked on a command that automatically imports a dwg into paperspace and positions it. I've just realized that when imported vertically, the titleblock is on the wrong side of the layout. I've imported it to (10,10,0) and would ideally like to import to those exact opposite co-ordinates to essentially flip it but i'm a bit unclear as to how. I know that I can use the commands  Database.PextMax  and Database.PextMin to determine the max and min points of the primary layout, but what co-ordinates are these, are they the top right corner and bottom right corner, how do i tell? Also, is there any documentation on these commands?

 

Thanks

Vince

 

 

For what it's worth, here's my routine:

 


string dwgName = HostApplicationServices.Current.FindFile(comp, acadApp.DocumentManager.MdiActiveDocument.Database, FindFileHint.Default);

Database db1 = new Database(false, false);

db1.ReadDwgFile(dwgName, System.IO.FileShare.Read, true, "");

ObjectId BlkId;

BlkId = doc.Database.Insert(dwgName, db1, false);

BlockTable bt = (BlockTable)tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead, true);

BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.PaperSpace], OpenMode.ForWrite);

BlockReference bref = new BlockReference(new Autodesk.AutoCAD.Geometry.Point3d(10, 10, 0), BlkId);

btr.AppendEntity(bref);

tr.AddNewlyCreatedDBObject(bref, true);

bref.ExplodeToOwnerSpace();

bref.Erase();

tr.Commit();
}
finally
{
tr.Dispose();
}
}
}

14 REPLIES 14
Message 2 of 15
Irvin
in reply to: vince1327

Hello vince,

 

If i understand your question please look at the next lines:

 

'these sysvars gives us the true LL and UR paper edges

pvEdge1 = ThisDrawing.GetVariable("LIMMIN")

pvEdge2 = ThisDrawing.GetVariable("LIMMAX")

 

 

 

Kind regards IrvinNaamloos.jpg

Message 3 of 15
vince1327
in reply to: Irvin

Ok awesome thanks, is it possible to re-assign the grip points of my block? So for example, i have a vertical titleblock that I would like to position on the right hand side of the page. The only point i have that is constant regardless of page size is my LIMAX. Unfortuantely my grip point of my titleblock is the lower right corner, so when i assign it its new coordinates, it flys almost entirely off the page. Ideally i'd like to position it using the lower right hand corner.

 

Thanks

 

Message 4 of 15
Irvin
in reply to: vince1327

I don't understand you question verry whell but if you mean you got a stamp and you need to insert this on the lower left corner you can you the x coordinate of limitmax .

 

so your insertionpoint whill be (limitmax x, limitmin y)

 

Kind regards,

 

Irvin

Message 5 of 15
vince1327
in reply to: Irvin

Thanks Irvin, i'm actually trying to insert my block on the lower left-hand corner. If i use limit-max, my block goes off the page.

 

Cheers

Message 6 of 15
Irvin
in reply to: vince1327

Hi there,

 

If you need to change the insertion point of the block you can open that block in the block editor.

 

The 0,0 coordinate is the insertion point from that block. If you move the entity's you can change the insertion point

 

Irvin

Message 7 of 15
vince1327
in reply to: Irvin

Excellent, i've just figured it out, thank you!

Message 8 of 15
vince1327
in reply to: Irvin

Actually just one last question, how would I get the limits in paperspace?

Message 9 of 15

From searching help for 'drawing limits': Pextmin and Pextmax - Returns the extents of the current Paper space layout.

Steven Elliott

When I was a little bitty boy, my grandmother bought me a cute little toy. Silver bells hangin' on a string... she told me it was my ding-a-ling-a-ling!
Message 10 of 15

Thanks, i've set the blockreference as follows

 

BlockReference bref = new BlockReference(pMax, BlkId);

 

and i've set up the switches for pMax as follows:

 

string comp = "";

//these are the switches based upon the value sent by the form
if (y == 1)
{ comp = "C:\\ACADSTUFF\\tbmetric.dwg";
pMax = new Point3d(10, 10, 0);
}

if (y == 2)
{ comp = "C:\\ACADSTUFF\\tbmetricv.dwg";
pMax = new Point3d(db.Pextmax.X, 10, 0);
}

if (y == 3)
{ comp = "C:\\ACADSTUFF\\tbimperial.dwg";
pMax = new Point3d(10, 10, 0);
}

if (y == 4)
{ comp = "C:\\ACADSTUFF\\tbimperialv.dwg";
pMax = new Point3d(db.Pextmax.X, 10, 0);
}

 

but what i've noticed is that my block automatically imports at it's co-ordinates from it's original dwg. Even though i've specified a position a pMax, it won't obey. Am i doing something wrong or is this just a limitation?

Message 11 of 15
Hallex
in reply to: vince1327

Take a look at online docs:

 

http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer%27s%20Guide/index.html?url=WS1a9193...

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 12 of 15
vince1327
in reply to: Hallex

Thanks for this, unfortunately i still can't seem to import my block at a specified postiion. This guide is great for modifying my views though, thanks.

Message 13 of 15
vince1327
in reply to: vince1327

I'll leave it for now, it seems to be working even though it shouldn't be, thanks to everyone for their help! As always, much appreciated

Message 14 of 15
Hallex
in reply to: Hallex

I think I've found why this  trouble may be occurs

Take a look at:

http://autocadtips.wordpress.com/2011/10/04/layout-tab-cooridinates/

 

Hth

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 15 of 15
vince1327
in reply to: Hallex

I didn't even realize that this was an option, thanks! 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost