Author Topic: Beginner: Block Insert Redefinition  (Read 1697 times)

0 Members and 1 Guest are viewing this topic.

Offline chillme1

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
  • Gender: Male
    • prefered language: VB
    • Prog expertise: Beginner
    • View Profile
Beginner: Block Insert Redefinition
« on: June 21, 2011, 06:17:38 PM »

target audience:{intermediate}

Could someone step me through via VB.NET code snippet or pseudo code on how to update block inserts existing in a specified directory by referencing the directory or directories that contain the source block DWG files?

Offline KPM

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
  • Gender: Female
    • prefered language: VB
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #1 on: July 12, 2011, 08:28:05 PM »
 :pasmal:
Has anyone been able to respond to this one yet? I need to be able to insert a block from an outside drawing and only see how to insert a block from creating one and then updating the definition during the routine/code (Jerry Winters book). There may be a more direct way when a user needs to insert a block from an outside drawing/block? Any code examples would be appreciated (vb.net please)

Offline (gile)

  • C#
  • *
  • Posts: 87
  • Karma: +8/-0
  • Gender: Male
    • prefered language: F
    • Prog expertise: Good
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #2 on: July 12, 2011, 10:17:48 PM »
Hi,

You can see in this thread at TheSwamp a 'step by step' to deal with block insertions. The first topics are about inserting a dwg using the Database.ReadDwgFile() and Database.Insert() methods.
Codes are provided in C#, F# and VB.

Offline KPM

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
  • Gender: Female
    • prefered language: VB
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #3 on: July 22, 2011, 11:38:10 PM »
This was great..now i have to get the block/drawing to insert as an annotative block. the block i'm using is annotative, but when i run my routine, it inserts it as false.
(when i assign isAnno=databasein.annotativeDWG is shows up as false, even though block's drawing is annotative.)

when i insert the block into the drawing and make it annotative and then rerun the routine, then the blocks come in annotative.

i think i must not have a setting included. I do try to reassign the blocktablerecord if IsAnno=false using myblockref.Annotative=AnnotativeStates.true, but it doesn not take. Any ideas?

Offline Jeff H

  • Newbie
  • *
  • Posts: 10
  • Karma: +3/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #4 on: August 03, 2011, 02:59:45 PM »
Take a look at
http://www.theswamp.org/index.php?topic=34494.msg397770#msg397770

and notice the part
Code: [Select]
            If btr.Annotative = AnnotativeStates.True Then
                Dim ocm As ObjectContextManager = db.ObjectContextManager
                Dim occ As ObjectContextCollection = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES")
                ObjectContexts.AddContext(bref, occ.CurrentContext)
            End If

You can also find your answers @TheSwamp

Offline KPM

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
  • Gender: Female
    • prefered language: VB
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #5 on: August 10, 2011, 09:46:27 PM »
I tried all sorts of ways to get that to work and wasn't able to get it to take. Maybe I have my code set up in such a way that won't allow it.

Offline Jeff H

  • Newbie
  • *
  • Posts: 10
  • Karma: +3/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #6 on: August 11, 2011, 09:58:08 AM »
Sorry from a external drawing.

Are yoou inserting the whole drawing or a block from the drawing?

Do have a example of what you have so far?

You can also find your answers @TheSwamp

Offline KPM

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
  • Gender: Female
    • prefered language: VB
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #7 on: August 12, 2011, 02:46:00 PM »
i am inserting a "drawing".

we have symbols we use on maps stored in a folder on our system which we would like to be able to have the user select the file to insert it as a routine, which it does. Unfortunetly, it does not insert it as annotative. it works if the block already exists in the drawing that you are running the program.. I've tried all sorts of combinations and the instructions, but i guess i'm missing something. I've thought about solving this thing using clones, but it seems from what i've read you need to have the block inserted into the drawing as a defined block from the drawing that you're trying to clone it from.

I have the code if you would like to look at it. Let me know and i'll attach w/the next post.

Offline KPM

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
  • Gender: Female
    • prefered language: VB
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #8 on: August 12, 2011, 06:32:29 PM »
Please find attached code/proj for review.

Offline Jeff H

  • Newbie
  • *
  • Posts: 10
  • Karma: +3/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #9 on: August 12, 2011, 09:36:35 PM »
I was having a little trouble follwing it needs to be updated but if it is working for you then great.

I guess it must be the InsertBlock function causing trouble.

around line 358 try this and see if it helps.


Change
Code: [Select]
            Dim myblockdef As BlockTableRecord = _
            myBlocktable(BlocknameOnly).GetObject(OpenMode.ForRead)

to
Code: [Select]
            Dim myblockdef As BlockTableRecord = _
            myBlocktable(BlocknameOnly).GetObject(OpenMode.ForWrite)
            myblockdef.Annotative = AnnotativeStates.True

change OpenMode to ForWrite and add following line

You can also find your answers @TheSwamp

Offline KPM

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
  • Gender: Female
    • prefered language: VB
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #10 on: August 12, 2011, 10:06:23 PM »
ah Haaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!!!! it works!

ugh. i was trying everything.....


thanks so MUCH Jeff!!!!

(this is my first vb.net converted program and had some stumbling blocks along the way. I would clean it up but would probably break it ....Hopefully my next one will go smoother. Thanks again for all your help!)

Offline KPM

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
  • Gender: Female
    • prefered language: VB
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #11 on: August 31, 2011, 08:24:14 PM »
thanks again for your help. the code works now, but something strange happens. when i run the routine, it works properly on the file that i use to insert the annotative wells into......they take the annotative property. However, when i xref the file into another drawing, the attributes show themselves as an incorrect size (way larger) than they are shown in the base drawing  they were inserted into. any ideas on where i should start trouble shooting?

Offline KPM

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
  • Gender: Female
    • prefered language: VB
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #12 on: September 14, 2011, 09:56:00 PM »
ok....i think i know why this is happening. on my initial tests i was using a block with an attribute that did not use multiline text. when i started testing on other blocks in our system which are using multiline text for it's attribute, the text scales incorrectly. I think it is because it is multiline and that the extra line that allows for text input may be throwing the program off. Any suggestions on where to start looking at fixing this? do i need to include a type of line code that tells the program to automatically get out of the text entry of the multiline?....still searching online and in the autodesk online stuff...

Offline Jeff H

  • Newbie
  • *
  • Posts: 10
  • Karma: +3/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #13 on: September 15, 2011, 05:21:52 AM »
You would have to upload a drawing to look at so I could look at it and maybe see if I can figure out your problem.

You could also look here



http://www.theswamp.org/index.php?topic=37686.msg427172#msg427172
« Last Edit: September 21, 2011, 01:17:33 AM by Jeff H »
You can also find your answers @TheSwamp

Offline KPM

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
  • Gender: Female
    • prefered language: VB
    • Prog expertise: Beginner
    • View Profile
Re: Beginner: Block Insert Redefinition
« Reply #14 on: September 20, 2011, 09:39:13 PM »
ok. see attached. Thanks!

The block i'm using is multiline annotative. the program inserts the wells utilizing an asc well coordinate file.