get block name from anonymous block name (*U type blocks)
Hi.
I'm trying to get the effective block name from a parametric block,
for example - in the list I get *U22 where what I need is "PVC PIPE DN140 PN10 ID-129.2 BELL_DY".
I've made several attempts but failed.
I attached here a sample drawing and the lisp I have so far.
thanks,
aridzv.
I'm trying to get the effective block name from a parametric block,
for example - in the list I get *U22 where what I need is "PVC PIPE DN140 PN10 ID-129.2 BELL_DY".
I've made several attempts but failed.
I attached here a sample drawing and the lisp I have so far.
thanks,
aridzv.
0
Comments
-
Perhaps this post may help -
Autodesk forum0 -
hi Arid,
try
(setq instHandle (BmLispGet "Instance" ent))
(setq instName (BmLispGet "InstanceName" instHandle))
(print instName)0 -
@Jason Bourhill
Hi.
I saw this old post of yours.
is there a way to use your code in my lisp?
thanks,
aridzv.0 -
Not sure I understand the question. But if you just want the block name from the reference,
This would be fairly easy in BRX or .NET. I’m using Python but the concept is the same
out
def PyRxCmd_doit():
try:
filter = [(Db.DxfCode.kDxfStart, "INSERT")]
ssResult = Ed.Editor.select(filter)
if ssResult[0] != Ed.PromptStatus.eNormal:
return
for refid in ssResult[1].objectIds():
#this is the "insert"
blkref = Db.BlockReference(refid)
#get the name from the BlockTableRecord
btrrec = Db.BlockTableRecord(blkref.blockTableRecord())
print(btrrec.getName())
except Exception as err:
print(traceback.format_exc())
GASKET 4In PN16_3d
*U22
*U21
GASKET 4In PN16_3d0 -
Hi @NigelTufnel.
The problem I have is to get the block name (I.e. "PVC PIPE DN140 PN10 ID-129.2 BELL_DY")
Instead of the *U21 and *U22...0 -
Hi, that's not the name, but an attribute.
I'm sure there's lots of lisp routines to get attributes
def PyRxCmd_doit():
try:
filter = [(Db.DxfCode.kDxfStart, "INSERT")]
ssResult = Ed.Editor.select(filter)
if ssResult[0] != Ed.PromptStatus.eNormal:
return
for refid in ssResult[1].objectIds():
blkref = Db.BlockReference(refid)
for attid in blkref.attributeIds():
att = Db.AttributeReference(attid)
print("Tag = {}, Value = {}: ".format(att.tag(),att.textString()))
except Exception as err:
print(traceback.format_exc())
Tag = ITEM_DESCRIPTION, Value = PVC PIPE DN140 PN10 ID-129.2 BELL:
Tag = ORDER, Value = 2:
Tag = QUANTITY, Value = 0.37:
Tag = UNIT, Value = M:
Tag = GRUOP, Value = PVC PIPES BELL:
Tag = SYSTEM, Value = :0 -
@NigelTufnel
Hi.
It is the block name,look in the sample dwg on the block name,
Not the attribute "ITEM_DESCRIPTION"
aridzv.0 -
I see, I had opened the drawing in AutoCAD, snooping around in BricsCAD, I see a BDM_DATABASE attached. Not sure how to access that data. I’m guessing it contains a handle to the insert.
Sorry about that
0 -
Asked at Cadtutor as well.0
-
there's this
https://developer.bricsys.com/bricscad/help/en_US/V23/DevRef/index.html
(vl-load-mech)
(mech:get-effectiveblocktablerecord (entget(car(entsel))))
i get
; error : no function definition ; expected FUNCTION at [eval]
maybe someone with mechanical can help
0 -
@NigelTufnel
First of all I have to praise the Bricscad technical support and thank them for the help they gave me.
without that help I would not have solved the problem.
the way to get the effctive name of anonymous block (*U TYPE) in bricscad is:(setq bname (getpropertyvalue ent_n "EffectiveName~Native"))
And here is a simple lisp that demonstrates it:(defun c:test ( / bname bname1 ensel obj ) (vl-load-com) (setq ensel (entsel "\nSelect Block: ")) ;;select an anonymous block (*U TYPE) to get it's name (setq obj (car ensel)) ;;set the block object to an Entity name varaible (setq bname1 (vla-get-effectivename (vlax-ename->vla-object obj))) ;; get the *U name (princ bname1) (setq bname (getpropertyvalue obj "EffectiveName~Native")) ;; get the effective name ;;(princ bname) ;; print the effective name )
I also attched here the final lisp.
regards,
aridzv.0