Hello,
I'm hoping this is a silly question. I'm trying to correct the position of a dynamic block using calculated coordinates. Preferably not using the move command as that adds a layer of potential error.
This would be easy with a non-dynamic block, I just used (setpropertyvalue "Position/X" Northing) and it worked fine. I tried using LeeMac's (LM:setdynpropvalue) which works for the rest of the properties, but not with "Position/X" or "Insertion point X", which are what shows up when I do a dump of the block.
Failing that, I know a block can be temporarily treated as a dynamic block with (vlax-ename->vla-object a), can a dynamic block be temporarily treated as a regular one for one command?
The subfunction is here:
The full LISP is attached but is rather large. Thanks for any pointers.
Solved! Go to Solution.
Solved by CodeDing. Go to Solution.
@Gorra ,
You can set the position of a Dynamic Block using the same "Position/X" & "Position/Y" methods.
As seen here:
So, something else must be going wrong with your lisp.
Most people struggle with troubleshooting WHAT the ACTUAL problem IS. (That's the hardest part is finding it)
If it says something like:
"; error: bad argument type: numberp: nil"
Then, that means one of your variables is likely set to "nil" accidentally and a function using that variable expected it to be a number. You will have to find the definition(s) of that variable and test where it could be going wrong.
What does your command history say when you run your command?
What happens when you run your code while using the "setpropertyvalue" functions?
(defun FixSplcCs (blk / GripDist_X GripDist_Y OldAnno_X NewAnno_X OldAnno_Y NewAnno_Y TrgIns_X TrgIns_Y)
(setq GripDist_X (LM:getdynpropvalue blk "SPLICE GRIP X"))
(setq GripDist_Y (LM:getdynpropvalue blk "SPLICE GRIP Y"))
(if (or (/= GripDist_X 0)
(/= GripDist_Y 0)) ; if either case grip point is non-zero
(progn ; then correct block position
(setq Insert_X Northing)
(setq Insert_Y Easting)
(setq OldAnno_X (LM:getdynpropvalue blk "SPLICE#/MODEL GRIP X"))
(setq OldAnno_Y (LM:getdynpropvalue blk "SPLICE#/MODEL GRIP Y"))
(setq TrgIns_X (+ Insert_X GripDist_X))
(setq TrgIns_Y (+ Insert_Y GripDist_Y))
(setq NewAnno_X (- OldAnno_X GripDist_X))
(setq NewAnno_Y (- OldAnno_Y GripDist_Y))
(setpropertyvalue blk "Position/X" TrgIns_X)
(setpropertyvalue blk "Position/Y" TrgIns_y)
(LM:setdynpropvalue blk "SPLICE GRIP X" 0)
(LM:setdynpropvalue blk "SPLICE GRIP Y" 0)
(LM:setdynpropvalue blk "SPLICE#/MODEL GRIP X" NewAnno_X)
(LM:setdynpropvalue blk "SPLICE#/MODEL GRIP Y" NewAnno_Y)
(setq Northing TrgIns_X)
(setq Easting TrgIns_Y)
);progn
;else
(progn
(setq Northing (getpropertyvalue blk "Position/X"))
(setq Easting (getpropertyvalue blk "Position/Y"))
);progn
);if
);defun
When I use (setpropertyvalue blk "Position/X" TrgIns_X) I get
Command: ; error: invalid data type or data overflow: #<VLA-OBJECT IAcadBlockReference 000002025e981348>
When I use (LM:setdynpropvalue blk "Position/X" TrgIns_X), I don't get an error, but it doesn't do anything.
When I use (setpropertyvalue blk "Position/X" TrgIns_X) I get
Command: ; error: invalid data type or data overflow: #<VLA-OBJECT IAcadBlockReference 000002025e981348>
This means you are trying to pass an ActiveX entity name when you should be trying to pass an AutoLISP entity name.
Try this fix:
(setq blkTemp (vlax-vla-object->ename blk))
(setpropertyvalue blkTemp "Position/X" TrgIns_X)
(setpropertyvalue blkTemp "Position/Y" TrgIns_y)
Can't find what you're looking for? Ask the community or share your knowledge.