Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Insert block name=file name with VLisp in objectdbx documents

13 REPLIES 13
Reply
Message 1 of 14
Anonymous
706 Views, 13 Replies

Insert block name=file name with VLisp in objectdbx documents

I have:

Mark_New.dwg > 2d Entities, no attribs

Assembly.dwg > Block "Title"
Block "Mark" nested in "Title"
...

If I open Assembly.dwg and do Insert Mark=Mark_New.dwg
the block "Mark" is updated as Mark_New.dwg

How Can I do with with VLisp in objectdbx documents?

Open as odbx Mark_New.dwg copy the entities
Open as odbx Assembly.dwg and update the Block "Mark"

Is it possible?

--
Marc'Antonio Alessi

(vl-string-translate "1234567890" "ie@mst.lan" "499825513610716")
http://xoomer.virgilio.it/alessi
> 2D Parametric for 2000-2010 <
(strcat "I like " (substr (ver) 8 4) "!")
13 REPLIES 13
Message 2 of 14
Anonymous
in reply to: Anonymous

Have you tried the copyobjects method? It would seem that that would work.
Copy the objects from the source file's block definition to the destination
block definition. I'm not sure that will have the same exact effect though.

"Marc'Antonio Alessi" wrote in message
news:6343992@discussion.autodesk.com...
I have:

Mark_New.dwg > 2d Entities, no attribs

Assembly.dwg > Block "Title"
Block "Mark" nested in "Title"
...

If I open Assembly.dwg and do Insert Mark=Mark_New.dwg
the block "Mark" is updated as Mark_New.dwg

How Can I do with with VLisp in objectdbx documents?

Open as odbx Mark_New.dwg copy the entities
Open as odbx Assembly.dwg and update the Block "Mark"

Is it possible?

--
Marc'Antonio Alessi

(vl-string-translate "1234567890" "ie@mst.lan" "499825513610716")
http://xoomer.virgilio.it/alessi
> 2D Parametric for 2000-2010 <
(strcat "I like " (substr (ver) 8 4) "!")
Message 3 of 14
Anonymous
in reply to: Anonymous

be aware that updating a block def using vlisp is problematic, and updating
a block def that has become annotative may cause fatal errors.

--
TDP

First things first, but not necessarily in that order.

The Doctor
"Marc'Antonio Alessi" wrote in message
news:6343992@discussion.autodesk.com...
I have:

Mark_New.dwg > 2d Entities, no attribs

Assembly.dwg > Block "Title"
Block "Mark" nested in "Title"
...

If I open Assembly.dwg and do Insert Mark=Mark_New.dwg
the block "Mark" is updated as Mark_New.dwg

How Can I do with with VLisp in objectdbx documents?

Open as odbx Mark_New.dwg copy the entities
Open as odbx Assembly.dwg and update the Block "Mark"

Is it possible?

--
Marc'Antonio Alessi

(vl-string-translate "1234567890" "ie@mst.lan" "499825513610716")
http://xoomer.virgilio.it/alessi
> 2D Parametric for 2000-2010 <
(strcat "I like " (substr (ver) 8 4) "!")
Message 4 of 14
Anonymous
in reply to: Anonymous

> Have you tried the copyobjects method? It would seem that that would work.
> Copy the objects from the source file's block definition to the destination
> block definition. I'm not sure that will have the same exact effect though.

Yes, I am using copyobjects method but I have some problem and I am
looking for a sample.

I have not source file's block definition because the block is the file
itself, the block Mark is the file Mark_New.dwg.

Do you have a sample?

Thanks.

--
Marc'Antonio Alessi

(vl-string-translate "1234567890" "ie@mst.lan" "499825513610716")
http://xoomer.virgilio.it/alessi
> 2D Parametric for 2000-2010 <
(strcat "I like " (substr (ver) 8 4) "!")
Message 5 of 14
Anonymous
in reply to: Anonymous

> be aware that updating a block def using vlisp is problematic, and updating a
> block def that has become annotative may cause fatal errors.

The block is not annotative, I am looking for a method to update many
files without use of command.

Thanks for answer.

--
Marco
Message 6 of 14
Anonymous
in reply to: Anonymous

I have issues with vla-insertblock methods when the block in question was
dynamic and updating blockdef.

does objectdbx support vla-insertblock?
--
TDP

First things first, but not necessarily in that order.

The Doctor
"Marc'Antonio Alessi" wrote in message
news:6344756@discussion.autodesk.com...
> be aware that updating a block def using vlisp is problematic, and
> updating a
> block def that has become annotative may cause fatal errors.

The block is not annotative, I am looking for a method to update many
files without use of command.

Thanks for answer.

--
Marco
Message 7 of 14
Anonymous
in reply to: Anonymous

> I have issues with vla-insertblock methods when the block in question was
> dynamic and updating blockdef.

Yes, I heard something like that.


> does objectdbx support vla-insertblock?

No. I do not think.

From help:
InsertBlock Method
Inserts a drawing file or a named block that has been defined in the
current drawing.

--
Marco
Message 8 of 14
Anonymous
in reply to: Anonymous

Hi Marco,

I haven't tested this, but I think what you want to do in this case is use the
CopyObjects method with the "*MODEL_SPACE" block within Mark_New.dwg as the source of
copied objects. Make a list of those vla-objects.

Within the Assembly file delete all objects contained in the block definition "Mark".
Then CopyObjects from source list into the currently empty block definition "Mark".

HTH
Joe Burke

"Marc'Antonio Alessi" wrote in message
news:6344721@discussion.autodesk.com...
> Have you tried the copyobjects method? It would seem that that would work.
> Copy the objects from the source file's block definition to the destination
> block definition. I'm not sure that will have the same exact effect though.

Yes, I am using copyobjects method but I have some problem and I am
looking for a sample.

I have not source file's block definition because the block is the file
itself, the block Mark is the file Mark_New.dwg.

Do you have a sample?

Thanks.

--
Marc'Antonio Alessi

(vl-string-translate "1234567890" "ie@mst.lan" "499825513610716")
http://xoomer.virgilio.it/alessi
> 2D Parametric for 2000-2010 <
(strcat "I like " (substr (ver) 8 4) "!")
Message 9 of 14
dgorsman
in reply to: Anonymous

I have a routine that *does* use (vla-InsertBlock...), but the block has no attributes. I think the text alignment issue will crop up if you attempt to insert a block via ODBX.
----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 10 of 14
Anonymous
in reply to: Anonymous

> I have a routine that *does* use (vla-InsertBlock...), but the block has no
> attributes. I think the text alignment issue will crop up if you attempt to
> insert a block via ODBX.

Can you post a sample?

--
Marc'Antonio Alessi

(vl-string-translate "1234567890" "ie@mst.lan" "499825513610716")
http://xoomer.virgilio.it/alessi
> 2D Parametric for 2000-2010 <
(strcat "I like " (substr (ver) 8 4) "!")
Message 11 of 14
Anonymous
in reply to: Anonymous

{code}
;;Demonstration on how to redefine a block using vlisp and objectdbx.
;;Not intended for use as-is. No error checking.
;;Use at own risk.
;;D. C. Broad, Jr. 2010
(defun redefineblockdbx (block source destination / dbx
dbx2 msp msp2 blk blks2 objects
obdbx
)
(setq dbx (vla-getinterfaceobject ;document to be destination
(vlax-get-acad-object)
(setq obdbx (strcat "ObjectDBX.AxDbDocument."
(substr (getvar "acadver") 1 2)
)
)
)
)

(setq dbx2 (vla-getinterfaceobject ;document to become source.
(vlax-get-acad-object)
obdbx
)
)
(vlax-invoke-method dbx 'open (findfile destination))
(vlax-invoke-method dbx2 'open (findfile source))

(setq msp2 (vla-get-modelspace dbx2)) ;source document

(setq blks (vla-get-blocks dbx)) ;destination block coll
(setq blk (vla-item blks block)) ;destination block

(vlax-for n blk (vla-delete n)) ;delete existing items
(setq msp (vla-get-modelspace dbx)) ;get source modelspace
;;make a list containing all model space objects
(vlax-for n msp2 (setq objects (cons n objects)))
;;copy objects from source drawing to destination block
(vlax-invoke dbx2 'copyobjects objects blk)
;;save changes
(vlax-invoke dbx 'saveas (vla-get-name dbx))
;;release objects (may be unnecessary)
(mapcar 'vlax-release-object (list msp blk blks dbx dbx2))
;;exit quietly without reference count list
(princ)
)

{/code}

"Marc'Antonio Alessi" wrote in message
news:6344721@discussion.autodesk.com...
> Have you tried the copyobjects method? It would seem that that would
> work.
> Copy the objects from the source file's block definition to the
> destination
> block definition. I'm not sure that will have the same exact effect
> though.

Yes, I am using copyobjects method but I have some problem and I am
looking for a sample.

I have not source file's block definition because the block is the file
itself, the block Mark is the file Mark_New.dwg.

Do you have a sample?

Thanks.

--
Marc'Antonio Alessi

(vl-string-translate "1234567890" "ie@mst.lan" "499825513610716")
http://xoomer.virgilio.it/alessi
> 2D Parametric for 2000-2010 <
(strcat "I like " (substr (ver) 8 4) "!")
Message 12 of 14
Anonymous
in reply to: Anonymous

Example call:
(redefineblockdbx "door" "door.dwg" "test.dwg")

Posted function will fail miserably if 1)block does not exist in
destination.
and 2) source does not exist or cannot be found.

Posted function is not optimized in any way.

"Doug Broad" wrote in message
news:6345462@discussion.autodesk.com...
{code}
;;Demonstration on how to redefine a block using vlisp and objectdbx.
;;Not intended for use as-is. No error checking.
;;Use at own risk.
;;D. C. Broad, Jr. 2010
(defun redefineblockdbx (block source destination / dbx
dbx2 msp msp2 blk blks2 objects
Message 13 of 14
Anonymous
in reply to: Anonymous

> ;;Demonstration on how to redefine a block using vlisp and objectdbx.

Grazie mille.

--
Marco
Message 14 of 14
Anonymous
in reply to: Anonymous

Prego!

"Marc'Antonio Alessi" wrote in message
news:6345500@discussion.autodesk.com...
> ;;Demonstration on how to redefine a block using vlisp and objectdbx.

Grazie mille.

--
Marco

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

Post to forums  

Autodesk Design & Make Report

”Boost