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

Insert Dynamic Block As Anonymous By Deafult

19 REPLIES 19
Reply
Message 1 of 20
Anonymous
580 Views, 19 Replies

Insert Dynamic Block As Anonymous By Deafult

Is there a way to insert a dynamic block as anonymous?

Changing a property of the dynamic block after insertion
to make it anonymous will not work for what I need. It
needs to be anonymous upon insertion.

Off the top of my head, I suppose I could nest the dynamic
block inside a "container" block and explode upon insertion,
but that feels kinda kludgy.

Anyone have a trick up there sleeve?

--
Autodesk Discussion Group Facilitator
19 REPLIES 19
Message 2 of 20
Anonymous
in reply to: Anonymous

(vlax-invoke-method OBJ 'ConvertToAnonymousBlock)
--
Dann M Brower
CompuDie Inc.
Wire EDM Service
www.CompuDie.com
"Jason Piercey" wrote in message
news:5476290@discussion.autodesk.com...
Is there a way to insert a dynamic block as anonymous?

Changing a property of the dynamic block after insertion
to make it anonymous will not work for what I need. It
needs to be anonymous upon insertion.

Off the top of my head, I suppose I could nest the dynamic
block inside a "container" block and explode upon insertion,
but that feels kinda kludgy.

Anyone have a trick up there sleeve?

--
Autodesk Discussion Group Facilitator
Message 3 of 20
Anonymous
in reply to: Anonymous

It would have to be in a reactor to check the name upon insertion.
If it's the same block everytime.
Not sure exactly what you are looking for.
Message 4 of 20
Anonymous
in reply to: Anonymous

I need to keep the dynamic properties.

Sorry, I should of clarified that.

--
Autodesk Discussion Group Facilitator


"Dann Brower" wrote in message
news:5476355@discussion.autodesk.com...
(vlax-invoke-method OBJ 'ConvertToAnonymousBlock)
Message 5 of 20
Anonymous
in reply to: Anonymous

It is the same block every time, FWIW. I can't
have this particular block be defined, as an insert,
with its' effective name.

--
Autodesk Discussion Group Facilitator


"Dann Brower" wrote in message
news:5476381@discussion.autodesk.com...
It would have to be in a reactor to check the name upon insertion.
If it's the same block everytime.
Not sure exactly what you are looking for.
Message 6 of 20
Anonymous
in reply to: Anonymous

Hi Jason,

I wonder if Tony's CloneBlock idea might apply? IOW, copy the dynamic block to a temp
ODBX doc, change a property there, then copy the result back to the active document.

Just a guess... not tested.

Joe

"Jason Piercey" wrote in message
news:5476290@discussion.autodesk.com...
Is there a way to insert a dynamic block as anonymous?

Changing a property of the dynamic block after insertion
to make it anonymous will not work for what I need. It
needs to be anonymous upon insertion.

Off the top of my head, I suppose I could nest the dynamic
block inside a "container" block and explode upon insertion,
but that feels kinda kludgy.

Anyone have a trick up there sleeve?

--
Autodesk Discussion Group Facilitator
Message 7 of 20
Anonymous
in reply to: Anonymous

Hi Joe,

I'm currently using the ObjectDBX "scratch pad"
concept that Tony showed for other parts in this
application (it does work well).

I've thought about using it to solve this problem
but that doesn't lend itself to other methods of
insertion like drag-n-drop from Windows explorer.

Without going into great detail, I suppose the real
problem I'm facing is with the way my code handles
this specific dynamic block. Hoping to avoid time
spent re-writing code, I was looking for a "quick fix".

--
Autodesk Discussion Group Facilitator


"Joe Burke" wrote in message
news:5476439@discussion.autodesk.com...
Hi Jason,

I wonder if Tony's CloneBlock idea might apply? IOW, copy the dynamic block
to a temp
ODBX doc, change a property there, then copy the result back to the active
document.

Just a guess... not tested.

Joe
Message 8 of 20
Anonymous
in reply to: Anonymous

Jason,

Well, you are adding other complexities to your initial question. Right? 🙂

I'm glad to hear the basic "scratch pad" idea was in tune with your thinking.

Regards
Joe

"Jason Piercey" wrote in message
news:5476456@discussion.autodesk.com...
Hi Joe,

I'm currently using the ObjectDBX "scratch pad"
concept that Tony showed for other parts in this
application (it does work well).

I've thought about using it to solve this problem
but that doesn't lend itself to other methods of
insertion like drag-n-drop from Windows explorer.

Without going into great detail, I suppose the real
problem I'm facing is with the way my code handles
this specific dynamic block. Hoping to avoid time
spent re-writing code, I was looking for a "quick fix".

--
Autodesk Discussion Group Facilitator


"Joe Burke" wrote in message
news:5476439@discussion.autodesk.com...
Hi Jason,

I wonder if Tony's CloneBlock idea might apply? IOW, copy the dynamic block
to a temp
ODBX doc, change a property there, then copy the result back to the active
document.

Just a guess... not tested.

Joe
Message 9 of 20
Anonymous
in reply to: Anonymous

Yes adding some complexities. Guess I'll have
to re-think my code process and see what I can
come up with.

--
Autodesk Discussion Group Facilitator


"Joe Burke" wrote in message
news:5476540@discussion.autodesk.com...
Jason,

Well, you are adding other complexities to your initial question. Right?
:-)

I'm glad to hear the basic "scratch pad" idea was in tune with your
thinking.

Regards
Joe
Message 10 of 20
Anonymous
in reply to: Anonymous

Hi Jason,

Just curious, did you find a way to do it?

I see an empty anonymous block can be added to the blocks collection like this.

(setq anonblk (vlax-invoke *blocks* 'Add '(0.0 0.0 0.0) "*U"))

My thought there was maybe you could CopyObjects from the dynamic block definition to
the new anonymous block. I'm sure you could, but I don't see a way to copy the
dynamic block properties.

And an anonymous block can be inserted like this.

(vlax-invoke *mspace* 'InsertBlock '(0.0 0.0 0.0) "*U8" 1.0 1.0 1.0 0.0)

But if "*U8" is a modified dynamic block, the new block reference is not dynamic.

Joe

"Jason Piercey" wrote in message
news:5476665@discussion.autodesk.com...
Yes adding some complexities. Guess I'll have
to re-think my code process and see what I can
come up with.

--
Autodesk Discussion Group Facilitator
Message 11 of 20
Anonymous
in reply to: Anonymous

Jason, is your intent to have a dynamic block inserted in your drawing
*without* having a named block in the blocks collection? I'm not sure that
is possible.

If you are not worried about the blocks collection, just the insert, could
you create the DBlock with a "bad" default visibility parameter, and just
change the parameter on the inserted block to the "good" one? No visible
change would be required.

--
R. Robert Bell


"Jason Piercey" wrote in message
news:5476290@discussion.autodesk.com...
Is there a way to insert a dynamic block as anonymous?

Changing a property of the dynamic block after insertion
to make it anonymous will not work for what I need. It
needs to be anonymous upon insertion.

Off the top of my head, I suppose I could nest the dynamic
block inside a "container" block and explode upon insertion,
but that feels kinda kludgy.

Anyone have a trick up there sleeve?

--
Autodesk Discussion Group Facilitator
Message 12 of 20
Anonymous
in reply to: Anonymous

Also, regardless of your approach, doesn't the effective name still show up
in List or the Properties palette?

--
R. Robert Bell
Message 13 of 20
Anonymous
in reply to: Anonymous

Hi Joe,

I haven't had any extra time to spend on this yet.

My original thought was maybe there was something
you could add to a macro (my block, for the most
part, is inserted via a pull down menu) that would
force an anonymous definition to be inserted instead
of the effective named block. Quick "fix".

Lets see if I can explain this without boring everyone 🙂
I've got a dynamic weldsymbol block where the weld
types are controlled via dynamic grips, the remaining
nested components visible states are controlled via code,
as in (vla-put-visible < nested object >).

In an effort to not effect other anonymous blocks of
the same name, every time a nested objects' visibility
is modified a new anonymous block is created in place
of the old one.

The way my code is currently structured, if some blocks
are already anonymous and a new effectively named block
is inserted I get some unwanted modifications to these
new inserts upon executing my code (poor coding and/or
short sightedness on my part).

I think I can fix this code by cloning the dynamic block
reference (as Tony demonstrated) when the nested
objects' visibility is modified. I just need to sit down and
spend a little time with it to ensure no other side effects.


--
Autodesk Discussion Group Facilitator


"Joe Burke" wrote in message
news:5477907@discussion.autodesk.com...
Hi Jason,

Just curious, did you find a way to do it?

I see an empty anonymous block can be added to the blocks collection like
this.

(setq anonblk (vlax-invoke *blocks* 'Add '(0.0 0.0 0.0) "*U"))

My thought there was maybe you could CopyObjects from the dynamic block
definition to
the new anonymous block. I'm sure you could, but I don't see a way to copy
the
dynamic block properties.

And an anonymous block can be inserted like this.

(vlax-invoke *mspace* 'InsertBlock '(0.0 0.0 0.0) "*U8" 1.0 1.0 1.0 0.0)

But if "*U8" is a modified dynamic block, the new block reference is not
dynamic.

Joe
Message 14 of 20
Anonymous
in reply to: Anonymous

Hi Bob,

No that is not my intent. The effectively named
block can/must exist in the collection, I just don't
want any effectively named inserts. Something
like an "insert as anonymous" property in the
dynamic block definition itself would be prefect.

I've considered that visibility approach, but with
the other visibility issues I mentioned in response
to Joe, I get some unwanted side effects on the
existing insertions.

I think I can solve this with code reorganization
just haven't had enough time to investigate.

Thanks for the reply.

--
Autodesk Discussion Group Facilitator


"R. Robert Bell" wrote in message
news:5477939@discussion.autodesk.com...
Jason, is your intent to have a dynamic block inserted in your drawing
*without* having a named block in the blocks collection? I'm not sure that
is possible.

If you are not worried about the blocks collection, just the insert, could
you create the DBlock with a "bad" default visibility parameter, and just
change the parameter on the inserted block to the "good" one? No visible
change would be required.

--
R. Robert Bell
Message 15 of 20
Anonymous
in reply to: Anonymous

Yes it does, but that doesn't matter to me.

--
Autodesk Discussion Group Facilitator


"R. Robert Bell" wrote in message
news:5477942@discussion.autodesk.com...
Also, regardless of your approach, doesn't the effective name still show up
in List or the Properties palette?

--
R. Robert Bell
Message 16 of 20
tlindell
in reply to: Anonymous

I don't know if this helps or not, but if you insert a dblock, apply a parameter change, effectively changing it to an anonymous block name, and then change that parameter back to the default state, the block remains anonymous.
Message 17 of 20
Anonymous
in reply to: Anonymous

That is what I am doing now to make sure all
effectively named inserts become anonymous,
which works fine until I insert a new one.

I know this has to be somewhat difficult to fully
understand what I am after without knowing how
the block functions, and how any of the code is
written.

Thanks for the suggestion.


--
Autodesk Discussion Group Facilitator


wrote in message news:5477990@discussion.autodesk.com...
I don't know if this helps or not, but if you insert a dblock, apply a
parameter change, effectively changing it to an anonymous block name, and
then change that parameter back to the default state, the block remains
anonymous.
Message 18 of 20
Anonymous
in reply to: Anonymous

Jason,

You're certainly not boring me. 🙂

Something interesting usually follows from pushing the limits. For instance, I didn't
know an anonymous block can be inserted using the InsertBlock method until I tried
it.

Joe

"Jason Piercey" wrote in message
news:5477995@discussion.autodesk.com...
Hi Joe,

I haven't had any extra time to spend on this yet.

My original thought was maybe there was something
you could add to a macro (my block, for the most
part, is inserted via a pull down menu) that would
force an anonymous definition to be inserted instead
of the effective named block. Quick "fix".

Lets see if I can explain this without boring everyone 🙂
I've got a dynamic weldsymbol block where the weld
types are controlled via dynamic grips, the remaining
nested components visible states are controlled via code,
as in (vla-put-visible < nested object >).

In an effort to not effect other anonymous blocks of
the same name, every time a nested objects' visibility
is modified a new anonymous block is created in place
of the old one.

The way my code is currently structured, if some blocks
are already anonymous and a new effectively named block
is inserted I get some unwanted modifications to these
new inserts upon executing my code (poor coding and/or
short sightedness on my part).

I think I can fix this code by cloning the dynamic block
reference (as Tony demonstrated) when the nested
objects' visibility is modified. I just need to sit down and
spend a little time with it to ensure no other side effects.


--
Autodesk Discussion Group Facilitator
Message 19 of 20
Anonymous
in reply to: Anonymous

For those of you that are still following my ramblings
This code snippet and attached block demonstrates
the problem. Hopefully this helps clear things up
instead of my poor explanations.

Qucickie code hacked out of a larger application.

; function to obtain the names of visibility
; states for a given dynamic block object.
; Arguments:
; [blockRef] - vla-object, dynamic block reference
; returns a list of strings or nil
(defun getVisibilityStateNames (blockRef / lst n l result)
(if (= :vlax-true (vla-get-isdynamicblock blockRef))
(progn
(setq
lst
(vlax-safearray->list
(vlax-variant-value
(vla-getdynamicblockproperties blockRef))))
(setq n 0)
(setq l (length lst))
(while (< n l)
(setq item (nth n lst))
(if (= "Visibility" (vla-get-propertyname item))
(progn
(setq n (1+ l))
(setq result (vlax-get item 'allowedvalues))
)
(setq n (1+ n))
)
)
)
)
result
)

; function that simply applies the default
; visibility state for a block reference,
; in effect making it anonymous
(defun putDefaultVisibilityState (blockRef)
(if
(= (strcase (vla-get-effectivename blockRef) t)
(strcase (vla-get-name blockRef) t))

; assumption: first item in the list is the
; visibility state parameter for the weldSymbol
(vlax-put
(car (vlax-invoke blockRef 'getdynamicblockproperties))
'value
(car (getVisibilityStateNames blockRef))
)
)
)


; convert each block reference named "Test"
; to an anonymous definition before allowing
; user to modify any properties of the base
; definition
(defun anonymous (/ ss i blockRef)
(if
(setq
ss
(ssget
"x"
(list
'(0 . "INSERT")
(cons 410 (getvar "ctab"))
'(2 . "Test")
)
)
)
(progn
(setq i -1)
(repeat (sslength ss)
(putDefaultVisibilityState
(vlax-ename->vla-object
(ssname ss (setq i (1+ i)))))
)
)
)
)


(defun c:test (/ object)
(anonymous)
(setq object (nentsel "\nselect nest object: "))
(setq object (vlax-ename->vla-object (car object)))
(vla-put-visible object :vlax-false)
(command ".regen")
)


1. Load the code above
2. Insert the "test" block
3. Run the test command
4. Select the circle
5. Insert the "test" block again
6. Run the test command again.
7. Notice the circle disappears in the new insert 😞

Seems like such a silly problem to have overlooked
the first time. Nothing quite like a test vs. production
environment.

So anyway, I think instead of using the "anonymous"
function to ensure anonymous block definitions I can
wait for the user to select the insert then clone the
dynamic block reference via the method Tony showed
(in a previous discussion) and problem should go away.

I think.

--
Autodesk Discussion Group Facilitator
Message 20 of 20
Anonymous
in reply to: Anonymous

Quickly testing, that appears to work nicely.

--
Autodesk Discussion Group Facilitator


"Joe Burke" wrote in message
news:5476439@discussion.autodesk.com...

copy the dynamic block to a temp ODBX doc, change a
property there, then copy the result back to the active document.

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

Post to forums  

Autodesk Design & Make Report

”Boost