Jump to content

Recommended Posts

Posted
Quote

Which one do you think is better/cleaner?

If you are not using dynamic blocks, then you don’t need the effective name, if you do than the function getEffectiveNameFromBtrId

is fine, it's actually the same thing I'll be adding

 

Quote

how do I know about updates/new releases?

I make one about once per week. Otherwise, you will need to create a GitHub account and watch the project

  • Thanks 1
Posted

Hi @Danielm103 what I was asking that I used lisp to write a defun command name that loads the correct dvb then runs the correct module. I want the equivalent to the 2 line answer, you already have python code saved but not loaded. The python arx is  preloaded on start up.

 

Say what you would put in a menu button, Ribbon etc.

  • Like 1
Posted (edited)

@BIGAL

 

I use tihs 3 lines combination in both my "on_start.lsp" and "on_doc_load.lsp" files. 

(SETVAR "FILEDIA" 0)
(command "pyload" "C:\\Users\\USER\\AppData\\Roaming\\Bricsys\\BricsCAD\\Lsp\\Python\\Py_tablewithimagetoexcel.py")
(SETVAR "FILEDIA" 1)

 

for some reason when starting the software (bricscad V25) in the very first drawing it don't take effect,

but from the second onwards it is fine and I do use ribbon button for the Py_tablewithimagetoexcel command.

Edited by aridzv
Posted (edited)
10 hours ago, Danielm103 said:

If you are not using dynamic blocks, then you don’t need the effective name, if you do than the function getEffectiveNameFromBtrId

is fine, it's actually the same thing I'll be adding

 

I use parametric blocks that like dynamic blocks change their names to *U-Name when their parameters changes,

so "getEffectiveNameFromBtrId" it is...

thanks.

Edited by aridzv
Posted
12 minutes ago, aridzv said:

@BIGAL

 

I use tihs 3 lines combination in both my "on_start.lsp" and "on_doc_load.lsp" files. 

(SETVAR "FILEDIA" 0)
(command "pyload" "C:\\Users\\USER\\AppData\\Roaming\\Bricsys\\BricsCAD\\Lsp\\Python\\Py_tablewithimagetoexcel.py")
(SETVAR "FILEDIA" 1)

 

for some reason when starting the software (bricscad V25) in the very first drawing it don't take effect,

but from the second onwards it is fine and I do use ribbon button for the Py_tablewithimagetoexcel command.

 

"on_start.lsp" and "on_doc_load.lsp" may load in to BricsCAD at a different time then PyRx. If it’s loaded before PyRx, there is no pyload command

 

It’s why pyrx_onload.py was created

 

But if what you have is working for you, then, yay :)

 

  • Like 1
Posted (edited)

 

Ignore....🤦‍♂️

Edited by aridzv
Posted (edited)

O.K.......

forgot about it...

I changed the py function file name but didn't changed it in "loadPythonModule" string ...🤦‍♂️

now it is this way with the correct file name (Py_tablewithimagetoexcel.py):    

from pyrx import Ap

Ap.Application.loadPythonModule("C:\\Users\\Aridzv\\AppData\\Roaming\\Bricsys\\BricsCAD\\Lsp\\Python\\Py_tablewithimagetoexcel.py")

 

now it's working and no need for the calls from "on_start.lsp" and "on_doc_load.lsp" .

thanks!!

Edited by aridzv
  • Like 1
Posted
3 hours ago, aridzv said:

 

I use parametric blocks that like dynamic blocks change their names to *U-Name when their parameters changes,

so "getEffectiveNameFromBtrId" it is...

thanks.

Not sure the difference between “parametric blocks” and “dynamic blocks” from an API perspective. We’ll have to keep an eye on that

  • Like 1
Posted

It seems bricscad changed the behavior of parametric blocks in V25.

In previous versions changing a parameter would cause the block name to be renamed to anonymous with a *U prefix.

I had a lot of problems with this in the past and bricscad support showed me how to use lisp to get the effective name.

Posted

Do you have a sample of such a parametric block? I will make a unit test

Posted (edited)
10 minutes ago, Danielm103 said:

Do you have a sample of such a parametric block? I will make a unit test

@Danielm103

yes.

see attached dwg - insert it to a drawing and change d1 parameter.

PVC PIPE GRAY DN63-PN10 3d.dwg

Edited by aridzv
Posted (edited)

@Danielm103

In fact it still remains like this in V-25.

See two screenshots of the result of

(entget(car(entsel)))

The shorter block in the two screenshots is the original without changing the parameter d1,

and the longer one is with the change.

See that in the first "ASSOC 2" gives the real name and in the second it gives *U with some number i.e. anonymous block

entnamev25.jpg

entnamev24.jpg

Edited by aridzv
Posted

The way I get around "*u.." blocks is just get all the blocks, "insert,**U*" in a ssget. using (vl ax-get blk 'name) you can get the block name which will return "*U1123" but ( vlax-get blk 'effectivename) returns the true name, so can find the correct blocks.

 

(repeat (setq x (sslength ss))
 (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
 (setq bname (vlax-get obj 'effectivename))
 (if (wcmatch bname "*Door*")
 (progn

 

Posted

test fails, I'll need to ask Bricsys

Posted

Just a comment.

 

"C:\mypython projects\program name"

 

To @Danielm103 if you add "C:\mypython projects" to the support paths does it find "program name like lisp (load "program name")

Posted (edited)
38 minutes ago, Danielm103 said:

test fails, I'll need to ask Bricsys

 

@Danielm103

Sorry, I should have included this code and the example drawing in my previous comment.

 

(defun c:geteffectivenamebr (/ selblk blknm)
      (setq selblk (car(entsel "\nSelect block : ")))
      (setq blknm (getpropertyvalue selblk "EffectiveName~Native")) ;;Bricscad
      (alert blknm)
      (princ)
)

 

geteffectivenamebricscad.dwg

Edited by aridzv
  • Like 1
Posted
25 minutes ago, BIGAL said:

Just a comment.

 

"C:\mypython projects\program name"

 

To @Danielm103 if you add "C:\mypython projects" to the support paths does it find "program name like lisp (load "program name")

 

it does not, The loader does a find file for pyrx_onload.py, so you would need to add entries to pyrx_onload.

However, you can make pyrx_onload handle complex situations such as PYRELOAD. Or capture other application events

Here’s a sample template

 

# import
import traceback
from pyrx_imp import Rx, Ge, Gi, Db, Ap, Ed

# called when the app is loaded
def OnPyInitApp():
    print("\nOnPyInitApp")

# called when the app is inloaded
def OnPyUnloadApp():
    print("\nOnPyUnloadApp")

# called the pyreload command ic called on THIS module
def OnPyReload():
    print("\nOnPyReload")

# called when a drawing is opened
def OnPyLoadDwg():
    print("\nOnPyLoadDwg")

# called when a drawing is closed
def OnPyUnloadDwg():
    print("\nOnPyUnloadDwg")

# prefix PyRxCmd_ defines a command
# CmdFlags is optional, default is modal
@Ap.Command()
def mycommand(CmdFlags=Ap.CmdFlags.TRANSPARENT):
    try:
        print("Hello world!")
    except Exception as err:
        traceback.print_exception(err)

@Ap.LispFunction()       
# (mylisp '("hello world" 1 2 3 4 (1 10 100)))
def mylisp(args):
    try:
        return args
    except Exception as err:
        print(err)

 

Posted
43 minutes ago, aridzv said:

 

@Danielm103

Sorry, I should have included this code and the example drawing in my previous comment.

 

(defun c:geteffectivenamebr (/ selblk blknm)
      (setq selblk (car(entsel "\nSelect block : ")))
      (setq blknm (getpropertyvalue selblk "EffectiveName~Native")) ;;Bricscad
      (alert blknm)
      (princ)
)

 

geteffectivenamebricscad.dwg 33.17 kB · 0 downloads

 

Good tip! but fails for block table records, I opened a support request

 

#if defined (_BRXTARGET) && (_BRXTARGET >= 250)
    AcValue value;
    if (BrxDbProperties::getValue(impObj()->objectId(), L"EffectiveName~Native", value))
        return wstr_to_utf8(value);
#endif

 

Posted

Thinking about this, effectiveName night not be effective (punny)

especially if your wanting to show representations of dynamic blocks in different states.

Filenames are unique, by using effectiveName, you would overwrite files

Posted (edited)
6 hours ago, Danielm103 said:

Thinking about this, effectiveName night not be effective (punny)

especially if your wanting to show representations of dynamic blocks in different states.

Filenames are unique, by using effectiveName, you would overwrite files

In my case, and the purpose I created that table for in autocad\bricscad,

is to sum all the "items"(blocks) in the drawing by their "real" name and show their total quantity.

the lisp that creat the table use effectiveName to search and sum the blocks.

not how many instances of block name, but some up their "QUANTITY" attributed values and show the effectiveName, because *U5 will mean nothing to a pvc pipes supplier or a technician in the field...😁.

About different states of a parameteric block - in my case it doesn't matter because the only parameteric blocks I use is for pipes or profiles, and I show their cross section and that doesn't change.

the table created by python seems to already brings the effectiveName for the blocks name it use's for creating the .png images ,so in my case it is actually a "non issue" when I think about it.

 

Having wrote that - maybe some one else will need to show parameteric or dynamic blocks in different state.

 

aridz.

Edited by aridzv

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...